private static void ValidateAttributeValidation(ValidateAttribute attribute, object value, PropertyInfo property, Errors errors) { if (attribute.Required) { RequiredAttribute.Validate(property, value, errors); } if (attribute.MinLength > 0) { MinLengthAttribute.Validate(property, value, errors); } if (attribute.MaxLength > 0) { MaxLengthAttribute.Validate(property, value, errors); } }
private static Info ValidateMinLengthAttribute(PropertyInfo property, object value, MinLengthAttribute minLength, Errors errors) { if (!property.PropertyType.Equals(typeof(string))) { throw new ArgumentException("Invalid Argument Type"); } var strValue = value as string; if (strValue?.Length < minLength.Length) { return(property.GetInfo(InfoType.MinLengthObject)); } return(null); }