Question

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?

Was it helpful?

Solution

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 :)

OTHER TIPS

NHibernate Validator isn't suitable for dynamic rules, instead of that, is a Constraints Validation Framework, to validate objects. Besides that, you may achieve some dynamism using fluent configuration http://fabiomaulo.blogspot.com/2010/01/nhibernatevalidator-changing-validation.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top