6
Vote

NHibernate.Validator trunk breaking changes

description

I've been using NHibernate.Validator from the trunk to take advantage of the fluent configuration, unfortunately this means that there are some breaking changes with the NHibernateValidatorRulesProvider. I have created a patch but can't seem to upload it via the source code so I will attach my changes here.
 
Any questions / problems let me know.
 
Cheers
 
James

file attachments

comments

SteveSanderson wrote Mar 4, 2009 at 8:51 PM

James, thanks for submitting this patch. Your code looks good.

I can't apply the patch yet, because that code can't compile against the current official build of NHibernate.Validator (for instance, it relies on IMappingsProvider, which wasn't added to NHibernate.Validator until after its last release). As soon as there's a new release of NHibernate.Validator then I'll use your patch to ensure xVal is compatible with it.

It is, unfortunately, awkward when different open source projects depend on one another but don't have synchronised release schedules, and some people are using official builds, and others are working from trunk... For now it's best for xVal to target the official release of NHibernate.Validator.

josemr wrote Apr 4, 2009 at 6:41 PM

I'm also using NHibernate.Validator from the trunk but my approach involves using the ISharedValidatorEngine to get the mapping for a specific type, I consider this would be a better approach.

wrote Apr 4, 2009 at 6:41 PM

wrote Apr 4, 2009 at 6:41 PM

wrote Apr 28, 2009 at 2:08 PM

HowardvanRooijen wrote Apr 29, 2009 at 9:49 AM

Thanks for the patch. Works really well.

For anyone else who is applying it - you need to make the following change in your global.asax.cs file.

var provider = new NHibernateSharedEngineProvider();
NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;
xVal.ActiveRuleProviders.Providers.Add(new NHibernateValidatorRulesProvider());

jonaX wrote Jul 8, 2009 at 12:37 PM

Thanks for the patch! I was able to compile with NHibernate.Validator Version 1.2.0.1003. The problem is now how to complete the access in my Application. In the comment of HowardvanRooijen, it's suggested to use the following lines:

var provider = new NHibernateSharedEngineProvider();
NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider;
xVal.ActiveRuleProviders.Providers.Add(new NHibernateValidatorRulesProvider());

The problem is now after patching; the NHibernateValidatorRulesProvider class needs now two Arguments: the Validator Mode which is clear to me and an IMappingsProvider Object. I don't know where I should get the IMappingsProvider from. Or am I completely wrong? What is the suggested way of doing this? Thanks!

ozanyurt wrote Aug 10, 2009 at 5:48 PM

@ HowardvanRooijen thanks for the tip you save my life :)

wrote Sep 1, 2009 at 1:40 PM

wrote Dec 31, 2009 at 12:57 PM

regisbsb wrote Dec 31, 2009 at 1:00 PM

There is an implementation that uses NHibernate.Validator metadata. So you can use whatever you want and get the validation.
http://weblogs.asp.net/srkirkland/archive/2009/11/02/an-xval-provider-for-nhibernate-validator.aspx
Steve before aplying the patch it would be nice to compare the two providers.
Thanks.

wrote Jan 6, 2010 at 7:55 PM

leonardolima wrote Feb 13, 2010 at 12:10 PM

Hey....
Today..
What patch I should use? I´m using NHibernate 2.1.2 and NHibernate Validator 1.2

Thanks...

wrote Feb 14, 2013 at 12:14 AM