确定EntLib验证规则执行顺序的原因是:
鉴于以下内容:
<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")> _
当对象实例化中缺少TransactionID时,将需要以下附加的错误字符串:
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.
然而,似乎每个错误的实际顺序可能会不时发生变化。出现相同的错误,但顺序不同。
我通过单元测试发现了这一点,我知道数据没有改变,一次通过测试现在失败了。
有没有人碰到这个,并有解释?
感谢。