Gu provides an example of how you can create a custom validator that overrides RegularExpressionAttribute.
The advantage of this is that you do not need to create a custom template validator , but I cannot make it work.
Given the following code:
public class NameAttribute : RegularExpressionAttribute { public NameAttribute() : base(@"^[\w\s\-\']+$") { } }
It works:
[RegularExpression(@"^[\w\s\-\']+$")]
But this is not so:
[Name]
Did I not understand one aspect of Scott's example, or is it an example that MVC does not support derived types from the box, so will I actually have to create the corresponding ModelValidator?
source share