NHibernate Validator - how to validate enum type
Posted
by Herr W.
on Stack Overflow
See other posts from Stack Overflow
or by Herr W.
Published on 2010-03-17T22:57:31Z
Indexed on
2010/03/17
23:01 UTC
Read the original article
Hit count: 311
nhibernate
|validation
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.
© Stack Overflow or respective owner