NHibernate validator or Fluent Validation?

I use NHibernate. I need to decide how validate domain entities. What do you recommend? Are there any troubles if use NHibernate with Fluent Validation?

Answers


Fluent validation is really good for user input validation, and can be used for simple business rules. But it has no integration with NHibernate. That means that nothing would prevent NHibernate from saving not valid entity except your custom code.

On other hand there is a NHibernate validator project. It has an integration with nhibernate, and it won't let you to save not valid entity.


Of the O/RM tools I know, NHibernate has the smallest footprint in the C# code of domain classes. It almost allows working with POCO's while being totally oblivious of dependencies. That is exactly what FluentValidation allows too. So it seems like a happy marriage to me.

But I wouldn't dare recommend or advise against any validation tool or framework without knowing more of your context. There are many candidates and they would work with NHibernate as well. Data access and validation are two different concerns that should (and can) be separated from one another.


Generally your domain shouldn't know about your ORM. It should be kept in isolation. So my answer is: I Can not see any issue with NH and FNH Validation, but keep domain in isolation as much as possible.


Need Your Help

iOS 4.3: How to handle the logging message: “Received memory warning. Level=1”?

ios memory warnings

I have created a little app for my iPhone. When I run it on my device the output console sometimes logs the message

Layout divs side by side in jQuery tabs

html css

I have spent hours trying to figure out how to layout 2 divs next to each other in jQuery tabs. Normally, I just float:left both divs with some styling and they work out of the box. Is there some s...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.