예제 #1
0
        public bool Contains_IsValid(string lookingFor)
        {
            //Create Validator
            var validator = new Contains <Contact, IEnumerable>(lookingFor);
            RuleValidatorContext <Contact, IEnumerable> context = BuildContextForAliases(PopulateListAction.Populate);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
예제 #2
0
        public bool Contains_Expression_IsValid(string lookingFor)
        {
            //Create Validator - Aliases must contain FirstName
            var validator = new Contains <Contact, IEnumerable>(c => c.FirstName);
            RuleValidatorContext <Contact, IEnumerable> context = BuildContextForAliases(PopulateListAction.Populate);

            context.Instance.FirstName = lookingFor;

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }