The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Joerg Jooss (9) [Avatar] Offline
Table 8.1 shows PhoneNumber as validation attribute, but the attribute is actually called [Phone] (i.e. System.ComponentModel.DataAnnotations.PhoneAttribute.

Aside: Is [Phone] really used for validation? I see neither client side nor server side validation being used for a binding model with a [Phone] property (assuming 'asgdsg' doesn't qualify as valid phone number smilie). The same is true for DataType(DataType.PhoneNumber).
Andrew Lock (51) [Avatar] Offline
Thanks for picking that up, it should be
, not

The attribute should be used for validation on the server side at least (you can see the source code for it here:

I'll do some additional tests, and get back to you once I've confirmed
Joerg Jooss (9) [Avatar] Offline
As I said, I've tested this already--it doesn't validate in ASP.NET Core MVC, nor does it in MVC 5. Or I'm doing something wrong smilie
Andrew Lock (51) [Avatar] Offline
I've just double checked this, and the [Phone] attribute definitely validates correctly server side, but it doesn't include client side validation. You can see a working example if you look at the source code for the book and take a look at the chapter06/ValidatingWithDataAnnotations project.

Hopefully that will help!
Joerg Jooss (9) [Avatar] Offline
After fiddling with your sample, I found that a stumbled across a string of errors I had made that more or less hid the validation error.

Another thing I realized is that the integration with Bootstrap's form related classes has to be done manually. That's something that might be worth mentioning in section 6.3.4. (see the attached screenshot and how invalid fields are highlighted, whereas there's no additional visual cue on the input elements in figure 6.9 and 6.10).