Greg,

If you are starting new validation work I'd be taking a good look at this:

https://fluentvalidation.codeplex.com/

We've used it in a largish MVC project quite happily (I also wish we'd used
it in another project as it would have made conditional validation for
different clients a breeze via dependency injection).

It's very testable and very readable and just nice :)

Enjoy,

Neil.

On 7 October 2014 14:14, Greg Keogh <[email protected]> wrote:

> Using the Framework classes, is there is neat and easy way of annotating
> properties of a class with validation rules and then validating the rules
> to get the error(s)?
>
> I ask because the DataAnnotations
> <http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations(v=vs.110).aspx>
> namespace has dozens of attributes for defining the rules and data format
> of properties, but I can't find anything that then processes the rules to
> give you results. I get the impression these attributes are just for
> code-first.
>
> I can also implement IDataErrorInfo
> <http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo(v=vs.110).aspx>
> but it seems designed for use in UI binding and again I can't find who
> actually runs the validation.
>
> I just wanted to annotate a class with rules and then process then when I
> want with minimum effort, independent of the environment. Is there some
> trick I'm missing?
>
> *Greg K*
>

Reply via email to