Is it possible to specify a non-required field with a minimum length using Data Annotations?
It might sound odd, but I want a field for a phone number where I don't mind if it is complete, but if it is, I want it to be a minimum length!
Is it possible to specify a non-required field with a minimum length using Data Annotations?
It might sound odd, but I want a field for a phone number where I don't mind if it is complete, but if it is, I want it to be a minimum length!
From msdn Using Data Annotation Attributes
There is no capability to use Or composition, as there is with the Or composite validator in the Validation Application Block. The only composition available with data annotation validation attributes is the And operation.
Therefore it doesn't like you could use a combination of Range attributes. However you could look at using a regex for this instead. For that these should help