Use of the same attribute multiple times per property being validated

Topics: Wish List Forum
Dec 14, 2006 at 2:03 AM
Provide the ability to do the following:

private DateTime _orderDate;

EvilAttributes.ValidateDateOccursOnOrAfter("MinimumOrderDate", "Order Date must be on or after today's date")
EvilAttributes.ValidateDateOccursOnOrAfter("SignUpDate","Order Date must be on or after the customer's Sign Up Date")
public DateTime OrderDate
get { return _orderDate; }
set { _orderDate = value; }

Right now the second attribute on the OrderDate property will cause an error. I'm not sure if this is a limitation in the compiler or not, but it currently throws a compilation error when you attempt to do this.
Dec 14, 2006 at 3:44 AM

If I remember correctly from the HDC talk, some of the Validation Attributes have AllowMultiple = true

AttributeUsage(AttributeTargets.Property, AllowMultiple = true)

While others have
AttributeUsage(AttributeTargets.Property, AllowMultiple = false)

I would suspect that this would logically depend on what you are checking.

e.g. ValidateWholeNumberAttribute is AllowMultiple = false (what you are checking is or is not)

ValidateLessThanAttribute is AllowMultiple = true (you may want to check that a value is less than 2 or more other property values)

Looking forward to using this stuff.
Dec 18, 2006 at 4:17 AM
This has been taken care of in the next release.