Dario Quintana

at blogging

NHibernate Validator 1.3.2 GA

The last version of NHibernate Validator was published. You may find the here:

Source or Binaries

As you may notice, the sources are not longer at Sourceforge SVN, were moved to GitHub. For practical reasons the binaries still being published at Sourceforge.

NHibernate Validator on GitHub

MG_0914

Well, I just can said that: Finally! Now you can find NHibernate Validator source code here:

https://github.com/darioquintana/NHibernate-Validator

The source code is ready to use with the last GA version of NHibernate 3.2.0.

NHibernate Validator 1.2 Beta3 released

Download NHibernate Validator 1.2 beta3 with sources, binaries and example here here

For use it with NHibernate 2.1 GA.

For examples and documentation see the serie of blog posts of Fabio Maulo about NHibernate Validator here

NHibernate Validator 1.2 Beta2 released

Download NHibernate Validator 1.2 beta2 with sources, binaries and example here here

For use it with NHibernate 2.1 GA.

Enjoy it !

NHibernate Validator Quickstart

The NHibernate Validator Team had prepared examples to you be able to use this validation framework in a easy way. With four examples we are covering the following topics:

1) Winforms

In this example you will how you can easily integrate NHibernate Validator and some helper clases with System.Windows.Forms.

2) NHibernate Integration

Trying to integrate NHibernate Validator with NHibernate? Not a problem. In this example you will how really get these 2 great frameworks working together. NHibernate Validator let you intercept Saves and Updates from NHibernate validating your entities before these changes take place. Note you have to create a database based on the configured connection string.

3) Asp.Net MVC

Asp.Net MVC has a cool way to add validation errors from model and display them all into the View. This example cover the easy integration between these frameworks. Note, you need Asp.Net MVC installed into your machine.Download Asp.net MVC

4) Entity Validator

Sometimes you need to validate a property which depends of another(s) property(ies). The most common example is when you have to validate a range of dates. This example cover this funcionality and show to us how to configurate it using attributes, xml and fluent.

Download it here

NHibernate Validator and Asp.Net MVC

 Download the example here.

Asp.Net MVC has a cool way to add validation errors from the model and display them all into the View. It?s actually using the ModelState. As you may know NHibernate Validator (NHV) is a framework to validate entities, so what about if we let the validation to the framework that can manage it? So the integration of NHV to Asp.Net MVC is easy. I created a new Asp.Net MVC project and added some files to my solution to make they look like this:

First I added the libraries needed to NHV (this libraries we need in case to use NHibernate too, otherwise you don?t need Linfu stuff to get proxies working). The libraries are:

Once the libraries are referenced, NHV need to be initialized, actually in this example that initialization will consist in a Validator Engine provider, capable to be accessed from everywhere into our web-application. A good point do this, is in the Global.asax. The next method InitializeValidator it?s called from the Application_Start.

Then I created a new View Manage.aspx, actually the view is a copy, with modifications, of Register.aspx View. Such View should looks like this one. As you may see, seems like there are some messages of validation, means, a validation that didn?t pass.  Now let?s see the code to explore the minimal code to introduce NHibernate Validator as a Framework to Validate our MVC application.

First of all, our entity Customer, which reflex the view with a Name and a Email properties, should looks like this with the NHV attributes. Remember that NHV can be configured using Attributes (default), Xml or Fluent-Interfaces, and accept mix of configurations too.

Second, we need the integration point between NHibernate Validator and Asp.Net MVC, and that point consist just in a little piece of code that make the validation and modifies the current state of the model. We need just a few lines:

The picture shows an extension method which first of all, get a new ValidatorEngine instance, which is a singleton in whole web application. Actually, to use a ValidatorEngine we need just one instance, because NHV make a lot of useful caching and it configure itself in the way we are using it. Then we validate the entity and get all the InvalidValues of the object. If the entity is in invalid state (break one rule defined), NHV we well generate a InvalidValue array with all errors we should show to the user. Iterate through all the items and we add them all to the ModelState. Once we add one model error, the model is no longer valid.

Once we have our extension, let?s use it.

Validate Method is the extension we made before, and that method is going to modify the ModelState if it?s needed.

And that?s all folks, hope this helps.

NHibernate Validator 1.2 alpha3

Download NHibernate Validator 1.2 alpha3 with sources and binaries here

This release demostrate to be very stable and is an update to use it with NHibernate 2.1alpha2. For those who have NH.Validator 1.2alpha1 this is a mandatory update.

Enjoy it !

New NHibernate and NHibernate Validator releases

NHibernate Validator 1.0 CR1

I hope you enjoy this brandnew release of this amazing validator framework. Comes with more stability, more documentation, examples, and the most important point is the full compliance with NHibernate 2.0 GA.

Issues as usual must be reported in our issue-tracker.

Binaries, source and examples: download it here !

Beta1: NHibernate 2.0 y NHibernate Contrib Releases

Older Posts »