There is a similar usage of DataAnnotations described in an article at CodeProject - http://www.codeproject.com/Articles/256183/DataAnnotations-Validation-for-Beginner
I’ve found this method useful (initially discovered at MSDN Library here <http://msdn.microsoft.com/en-us/library/cc668224(v=vs.110).aspx> ). _____ Ian Thomas Albert Park, Victoria From: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] On Behalf Of Greg Keogh Sent: Tuesday, October 07, 2014 3:58 PM To: ozDotNet Subject: Re: Validation Finally found a way of using the DataAnnotations. This guy <http://aboutdev.wordpress.com/2009/12/20/poor-mans-validation/> points out the Validator <http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.validator(v=vs.110).aspx> class static methods. The code is a bit weird through, as you make a context with the thing to validate, then you call Validate on the thing, passing the context, so you give it the thing twice. You can derive from ValidationAttribute and make your own rules. The context is used to pass extra information to the validation processing, so you could put multiple things in a dictionary and validate them against each other. This suits my needs for now -- Greg On 7 October 2014 15:14, Greg Keogh <g...@mira.net> 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