views:

74

answers:

1

Hello,

I have a problem with the Microsoft EnterpriseLibrary validation framework.

Let's say we have a DateTime? field. When using the NotNullValidator with another validator (let's say, the datetime validator) I always run in an exception.

The scenario is: I pass a null value. The NotNullValidator works fine (it sets the validation issue) but then the other validator throws a NullReferenceException, trying to apply its rules to the null value I passed.

I tried putting a CompositeValidator with AND logic, hoping that if the first validator reported an issue, the following validators would be ignored (as it should with an AND logic) but I had no luck.

How is it possible to make coexists the NotNullValidator with other validators, having the first one take priority (obviously) over the others?

+1  A: 

The above is currently not possible. Unfortunately the Composite validator does not short circuit.

If you need to do it I would just write a custom validator , quick and relatively painless.

Nix