public bool MaxLength_IsValid(string propertyValue, int maxLength) { //Create Validator var validator = new MaxLength <Contact>(maxLength); RuleValidatorContext <Contact, string> context = BuildContextForLength(propertyValue); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }
public bool MaxLength_Expression_IsValid(string firstName, string lastName) { //Create Validator //FirstName Length must be at least the same length as the LastName var validator = new MaxLength <Contact>(c => (int)(c.LastName.Length)); RuleValidatorContext <Contact, string> context = BuildContextForLength(firstName, lastName); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return(validator.Validate(context, null, notification)); }
public bool MaxLength_IsValid(string propertyValue, int maxLength) { //Create Validator var validator = new MaxLength<Contact>(maxLength); RuleValidatorContext<Contact, string> context = BuildContextForLength(propertyValue); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return validator.Validate(context, null, notification); }
public bool MaxLength_Expression_IsValid(string firstName, string lastName) { //Create Validator //FirstName Length must be at least the same length as the LastName var validator = new MaxLength<Contact>(c => (int)(c.LastName.Length)); RuleValidatorContext<Contact, string> context = BuildContextForLength(firstName, lastName); var notification = new ValidationNotification(); //Validate the validator only, return true of no error returned return validator.Validate(context, null, notification); }