public bool Between_IsValid(int propertyValue, int floor, int ceiling) { //Create Validator var validator = new Between <Contact, int>(floor, ceiling); 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 Between_Expressions_IsValid(int propertyValue, int floor, int ceiling) { //Create Validator var validator = new Between <Contact, int>(c => c.NumberOfChildren, c => c.NumberOfDependents); RuleValidatorContext <Contact, int> context = BuildContextForNumberOfDependents(propertyValue); context.Instance.NumberOfDependents = ceiling; context.Instance.NumberOfChildren = floor; var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }
public bool Between_CeilingExpression_IsValid(string createDate, string startDate, string endDate) { DateTime createDateTime = DateTime.Parse(createDate); DateTime startDateTime = DateTime.Parse(startDate); DateTime endDateTime = DateTime.Parse(endDate); //Create Validator var validator = new Between <CalendarEvent, DateTime>(createDateTime, c => c.EndDate); RuleValidatorContext <CalendarEvent, DateTime> context = BuildContextForCalendarEventStartDate("Test Event", createDateTime, startDateTime, endDateTime); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }