views:

104

answers:

1

I'm using Nhibernate and I have a requirement that the validation rules must change in time. The framework I'll use is NHibernate validator, but I don't really know how to make dynamic rules, the validation is quite simple with xml files or attributes in the entity class, but the catch is to make this rules updatable. Is there a way to achieve this?

+1  A: 

Well, since nobody answered this I'll explain how can it be achieved. It can be done with special attributes within the class like [Email] [NotNull] [NotEmpty] etc, and they can be changed/overridden with xml files. In the configuration file of the NHibernate validator add tags for each one of the classes that should be controled like this:

<mapping file="path.to.xml.validation.file">

and change the *default_validator_mode* property to OverrideAttributeWithExternal

Hope this helps :)

Argons