O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

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

Validating complex business rules

To validate complex business rules, attributes are not enough. In this case, we need some alternatives.

Enforcing always valid entities

One way to validate the data entered by the user is to require the entities and value objects in our domain model to always be in a valid state and reject any data changes if this rule is violated. If we postulate that in our domain, entities and value objects can always only be in a valid state, then we have to write much less error-handling code. Any code dealing with entities can always assume that the respective entity is in a valid state.

How can we achieve an entity or a value object that is always in a valid state? Let's look at a simple example: our application has a person ...

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