开发者

MS Enterprise Library validation problem

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 NullRe开发者_Python百科ferenceException, 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜