I have a Entity Framework model class that has a view to create an instance of that model class. I wanted to validate dates on that class so that users add dates that meet certain criteria. I have a metadata class that uses attributes from the System.ComponentModel
and System.ComponentModel.DataAnnotations
namespaces.
Is there any attribute from there that I can use to perform the validation or is there some other way I can do this?
You'll need a CustomValidationAttribute, as existing attributes don't know their "object" (each property has no idea of other properties of the instance).
But my choice would go to FluentValidation, which has a nice fluent interface and give you the choice to interact between the properties of the object to validate.