I have a property annotated with a validation attribute. Why is the setter on the property called before the IsValid method of the attribute, and more importantly how do i get it to validate before setting the value ?
Here is a sketched code model to see how the validator attribute looks like:
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class MyAttribute: ValidationAttribute
{
public override bool IsValid(object value)
{
...
}
}
Here is how the attribute is used on the property:
[MyAttribute]
public string MyProperty
{
get { ... }
set { ... }
}