My problem with MVC validation is that I have a lot of different condition where different message needs to be shown and there isn't enough default attribute type for me to put all those message in. I am aware that I could create custom attribute to solve this problem, but then I realize a lot of the validation I want could be done with simple regex checking, so instead of creating multiple different classes I tried to find a way to have multiple regexp attribute on a property.
After some research I found this SO post which suggest simply to inherit the RegularExpressionAttribute class, which is EXACTLY what I want, but I couldn't do the actual implementation myself as I am fairly new to .NET.
Here's the suggested code:
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple=true)]
public class MultiRegularExpressionAttribute: RegularExpressionAttribute
{
...
}
can anyone help me fill the actual content of the class out? I tried to fiddle around and it ran without error, but the isValid method never got visited and I am so very lost.