I'm using nhibernate validator in my current solution. Everythings is almost fine but...
My view model has a property of type Gender (see example below)
public virtual Gender Gender { get; set; }
public enum Gender { Female = 1, Male = 2 }
Now i like to have some validation to ensure that the gender property ist set. But neither the NotEmpty nor the NotNull Attribute fulfil the requirement.
Is there a kind of a generic solution or best practice to handle enum validations.
Thanks in advance.
You can write a custom validator.
Here is a decent blog post about how to go about writing a custom validator .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.