示例#1
0
        public static IRuleBuilderOptions <T, TProperty> NotEmpty <T, TProperty>(this IRuleBuilder <T, TProperty> ruleBuilder)
        {
            ruleBuilder.Must((x, y) =>
            {
                if (y == null)
                {
                    return(true);
                }

                var specialChar = new List <char> {
                    '<', '>', '&', '"'
                };
                var hasResult = specialChar.Any(c => y.ToString().Contains(c));
                return(!hasResult);
            }).WithMessage("'{PropertyName}' should not have special character.");
            return(DefaultValidatorExtensions.NotEmpty(ruleBuilder));
        }
示例#2
0
 public CustomerViewModelValidator()
 {
     DefaultValidatorExtensions.NotEmpty(RuleFor(register => register.Name)).WithMessage("Customer name cannot be empty");
     DefaultValidatorExtensions.NotEmpty(RuleFor(register => register.Gender)).WithMessage("Gender cannot be empty");
 }
 public static IRuleBuilderOptions <T, TProperty> NotEmpty <T, TProperty>(this IRuleBuilder <T, TProperty> ruleBuilder)
 {
     return(DefaultValidatorExtensions.NotEmpty(ruleBuilder)
            .WithMessage(Errors.General.ValueIsRequired().Serialize()));
 }
 public static FluentValidation.IRuleBuilderOptions <T, TProperty> NotEmpty <T, TProperty>(this FluentValidation.IRuleBuilder <T, TProperty> ruleBuilder)
 {
     return(DefaultValidatorExtensions.NotEmpty(ruleBuilder).WithState(x => PropertyValidatorReason.Empty));
 }
 protected void ValidateName()
 {
     DefaultValidatorExtensions.NotEmpty(RuleFor(c => c.Name)).WithMessage("Please ensure you have entered the Name")
     .Length(2, 150).WithMessage("The Name must have between 2 and 150 characters");
 }
 protected void ValidateEmail()
 {
     DefaultValidatorExtensions.NotEmpty(RuleFor(c => c.Email))
     .EmailAddress();
 }
 protected void ValidateBirthDate()
 {
     DefaultValidatorExtensions.NotEmpty(RuleFor(c => c.BirthDate))
     .Must(HaveMinimumAge)
     .WithMessage("The customer must have 18 years or more");
 }
 public ConfigurationValidator(ILocalizationService localizationService)
 {
     DefaultValidatorOptions.WithMessage <ConfigurationNovellModel, string>(DefaultValidatorExtensions.NotEmpty <ConfigurationNovellModel, string>(base.RuleFor <string>((Expression <Func <ConfigurationNovellModel, string> >)((ConfigurationNovellModel x) => x.LdapPath))), localizationService.GetResource("Plugins.ExternalAuth.NovellActiveDirectory.fields.LdapPath.Required"));
 }