Reputation: 86957
Is it possible to use DataAnnotations
on an object and then .. programmatically, test to see if that object is Valid
or not?
I'm not using MVC3
or ModelBinding
or ASP.NET
.. but a WinForms
app.
Is this possible?
eg.
if (foo.IsValid) ? Hi() : Bye();
and the IsValid somehow checks each property that has DataAnnotations
on em, or something. ??
Upvotes: 1
Views: 114
Reputation: 86957
I know SLaks has answered my question, but here is another good, detailed description of the solution from Scott Allen :)
Upvotes: 0