Mid
ASP.NET Core
ASP.NET Core
Custom validation attributes?
Create custom rules by inheriting ValidationAttribute:
public class MustBeEvenAttribute : ValidationAttribute {
public override bool IsValid(object value) {
return (int)value % 2 == 0;
}
}
Use like:
[MustBeEven]
public int Number { get; set; }Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png