Adf.Base.Validation.MaxLengthAttribute.IsValid C# (CSharp) Method

IsValid() public method

Determines whether the specified value is valid for the supplied property.
public IsValid ( PropertyInfo propertyToValidate, object value ) : ValidationResult
propertyToValidate System.Reflection.PropertyInfo The supplied property.
value object The supplied value.
return ValidationResult
        public ValidationResult IsValid(PropertyInfo propertyToValidate, object value)
        {
            if (value == null) return ValidationResult.Success;

            return !value.ToString().HasMaxLength(length) ? ValidationResult.CreateError(propertyToValidate, "Adf.Business.AttributeMaxLengthInvalid", propertyToValidate.Name, length) : ValidationResult.Success;
        }