O'Reilly logo

NHibernate 3.0 Cookbook by Jason Dentler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating validator classes

In the previous recipe, we saw how to decorate our entity classes with NHibernate Validator. A better practice is to extract your validation rules to separate classes and avoid this dependency. In this recipe, I'll show you how to create validator classes, as well as an alternative method for configuring NHibernate Validator.

Getting ready

  1. Download the NHibernate Validator binary files from SourceForge at http://sourceforge.net/projects/nhcontrib/files/.
  2. Extract NHibernate.Validator.dll from the downloaded ZIP file to your solution's Lib folder.
  3. Complete the Eg.Core model and mappings from Chapter 1.

How to do it...

  1. Create a new class library project named Eg.ClassValidation.
  2. Add a reference to the Eg.Core model and NHibernate.Validator.dll ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required