Microsoft.Practices.EnterpriseLibrary.Validation 4.1 PropertyComparisonValidator

Jul 21, 2009 at 6:30 PM

I would like to compare a start date being less than or equal to an end date but the end date can be null.  If the end date is null the PropertyComparisonValidator continues with the validation and states the Start Date is greater than End Date.  I do not want a comparison if the end date is null

public DateTime StartDate { get; set; }

[NotNullValidator(Ruleset = "RuleSetFields",Negated=true)]

[PropertyComparisonValidator("StartDate", ComparisonOperator.GreaterThanEqual,
            Ruleset = "RuleSetFields", MessageTemplate = "Start date cannot be greater than End date.")]
public DateTime? EndDate { get; set; }

1) Tried the above

2) Tried the above without the negated=true

3) Tried without the Composition and Not Null attributes.

Thank you in Advance.

Jul 21, 2009 at 9:55 PM

Hi hardingja63,

You've reached the discussion forums for the CodePlex website itself. You'd probably see better success by posting this on the Enterprise Library project's discussion forums instead.