public bool LessThanEqualTo_IsValid(int propertyValue, int lessThanEqualTo) { //Create Validator var validator = new LessThanEqualTo <Contact, int>(lessThanEqualTo); RuleValidatorContext <Contact, int> context = BuildContextForNumberOfDependents(propertyValue); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }
public bool LessThanEqualTo_Expression_IsValid(string propertyValue, string lessThan) { DateTime propertyValueDateTime = DateTime.Parse(propertyValue); DateTime lessThanDateTime = DateTime.Parse(lessThan); //Create Validator var validator = new LessThanEqualTo <CalendarEvent, DateTime>(c => c.EndDate); // Build context for CalendarEvent containing a StartDate of propertyValue. RuleValidatorContext <CalendarEvent, DateTime> context = BuildContextForCalendarEventStartDate("Test Event", propertyValueDateTime, lessThanDateTime); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }