Пример #1
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string userName = value.ToString();

            if (UserUtilities.IsLengthValid50(value, validationContext) == false)
            {
                return(new ValidationResult("Max length is 50"));
            }
            else
            {
                return(ValidationResult.Success);
            }
        }
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (UserUtilities.IsLengthValid100(value, validationContext) == false && UserUtilities.IsEmail(value, validationContext) == false)
     {
         return(new ValidationResult("Must be valid email and Max length is 100"));
     }
     else if (UserUtilities.IsLengthValid100(value, validationContext) == false)
     {
         return(new ValidationResult("Max length is 100"));
     }
     else if (UserUtilities.IsEmail(value, validationContext) == false)
     {
         return(new ValidationResult("Must be valid email"));
     }
     else
     {
         return(ValidationResult.Success);
     }
 }
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if (UserUtilities.IsLengthValid50(value, validationContext) == false && UserUtilities.ContainsNumbers(value, validationContext) == false)
     {
         return(new ValidationResult("Numeric values required and Max length is 50"));
     }
     else if (UserUtilities.IsLengthValid50(value, validationContext) == false)
     {
         return(new ValidationResult("Max length is 50"));
     }
     else if (UserUtilities.ContainsNumbers(value, validationContext) == false)
     {
         return(new ValidationResult("Numeric values required"));
     }
     else
     {
         return(ValidationResult.Success);
     }
 }