I am using the Required attribute on via the WCF RIA Services Metadata class, with the Entity Framework underneath that.
I create a new entity, and let the view bind to the view model. User looks at it for awhile, clicks around, and then attempts to save it.
The scenario here is that the user did not tab or click into a fields with a required field attribute.
How do I ensure all the required fields have data prior to submitting the data?
Winforms has this same problem, and I use to cycle all the fields in the form to ensure all the validators have passed.
Do I have to re-write that base class for a page – AGAIN?
Is there not a way to ensure all attribute validations are fired before sending it back to the server? Do I have to use reflection and pick up all the fields with the Required attribute?
I’m using the Entity Framework, and I’ve researched INotifyDataErrorInfo – but that is used after a trip to the DB (as I understand it).
I know I’m not the first person that has hit this – yet in my research I can’t find a good example of this scenario.
Have you looked at Validator.ValidateObject in System.ComponentModel.DataAnnotations? I’m pretty sure it does exactly what your asking.