views:

27

answers:

0

What determines the order of execution of an EntLib validation rule:

Given the following:

<ValidatorComposition(CompositionType.And, Ruleset:="Default")> _
<NotNullValidator(MessageTemplate:="Transaction ID is required.", Ruleset:="Default")> _
<TypeConversionValidator(GetType(Int64), MessageTemplate:="Transaction ID must be numeric.", Ruleset:="Default")> _
<RangeValidator("0", RangeBoundaryType.Exclusive, "0", RangeBoundaryType.Ignore, MessageTemplate:="Transaction ID may not be 0.", Ruleset:="Default")> _
<StringLengthValidator(1, RangeBoundaryType.Inclusive, 19, RangeBoundaryType.Inclusive, MessageTemplate:="Transaction ID must be between 1 and 19 characters in length.", Ruleset:="Default")> _

When TransactionID is missing from an object instantiation, the following appended error string would be expected:

Transaction ID must be numeric.Transaction ID must be between 1 and 19 characters in length.Transaction ID may not be 0.Transaction ID is required.

However, it would seem that the actual order of each error can differ from time to time. The same errors appear, but in a different order.

I found this out through unit testing, where I knew the data had not changed, and the once passing tests were now failing.

Has anyone ran into this, and have an explanation?

Thanks.