I am trying to override the RequiredAttribute
in .net core and does not seem to work on asp.net core 1.1
Here is the test code
public class CustomRequiredAttribute : RequiredAttribute
{
public CustomRequiredAttribute():base()
{
}
public override string FormatErrorMessage(string name)
{
return base.FormatErrorMessage(name);
}
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
return base.IsValid(value, validationContext);
}
}
Once used on my model I am expecting the normal result like field is required
as I have not customized it yet and just calling base methods.
This does not seem to work as expected and just bypasses the required on both the client and server side.
The purpose of this is to add a validation message pulled from a db to the ErrorMessage
property.
data-val-required
attribute? – Refutative