public bool LessThan_IsValid(int propertyValue, int lessThan) { //Create Validator var validator = new LessThan <Contact, int>(lessThan); 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 LessThan_Expression_IsValid(string propertyValue, string lessThan) { DateTime propertyValueDateTime = DateTime.Parse(propertyValue); DateTime lessThanDateTime = DateTime.Parse(lessThan); //Create Validator var validator = new LessThan <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)); }