Пример #1
0
        public static KeyValuePair <string, FluentValidation.AbstractValidator <object> > GetValidator <T>(System.Reflection.PropertyInfo prop)
            where T : IDataValidators
        {
            Validators validator = ValidationManager.GetValidatorType <T>(prop);

            //TODO: Use IoC get validator by a factory
            switch (validator)
            {
            case Validators.EmailValidator:
                return(new KeyValuePair <string, FluentValidation.AbstractValidator <object> >(prop.Name, EmailValidator.CreateValidator(string.Empty, prop.Name)));

            case Validators.TextValidator:
            default:
                return(new KeyValuePair <string, FluentValidation.AbstractValidator <object> >(prop.Name, TextValidator.CreateValidator(string.Empty, prop.Name)));
            }
        }