コード例 #1
0
        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));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }