Or Composite Validator

Topics: Validation Application Block
Dec 5, 2007 at 11:20 AM
I have a field where I want to validate that the field is null, or if not null then within a certain condition, say, it is datetime filed and it should be greater than the another property. I have a filed like,

public Nullable<System.DateTime> ShipDate
public Nullable<System.DateTime> PurchaseOrderDate

When I set the validation inside the class file as,

MessageTemplate = "OrValidation Failed",
Ruleset = "ApprovalRuleSet")]
MessageTemplate = "PropertyComparisonValidatorFailed",
Ruleset = "ApprovalRuleSet")]
[NotNullValidator(MessageTemplate = "NotNullValidatorFailed",
Ruleset = "ApprovalRuleSet", Negated = true)]

it is working fine. But my problem is I want to set this same condition in web.config file. But in web.config if I set the OrCompositeValidator,PropertyProxyValidator and NotNullValidatorwith Negated =true it is not working correctly.

I got the error message "OrValidation Failed" and "NotNullValidatorFailed" if the property has values even I entered the shipdate is greater than the PurchaseOrderdate.

I got the error message "OrValidation Failed" and "PropertyComparisonValidatorFailed" if the proerty is Null.

Could someone help me out with this?