简体   繁体   中英

NHibernate Validator - how to validate enum type

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM