Class ValueLengthValidator
- Namespace
- CloudyWing.FormValidators
- Assembly
- CloudyWing.FormValidators.dll
Validation constraints a value does not exceed the length range.
public sealed class ValueLengthValidator : FormValidatorBase, IFormValidator
- Inheritance
-
ValueLengthValidator
- Implements
- Inherited Members
Constructors
ValueLengthValidator(string, string, long, Func<string, string, long, long, string>)
Initializes a new instance of the ValueLengthValidator class.
public ValueLengthValidator(string column, string value, long max, Func<string, string, long, long, string> customErrorMessageAccessor = null)
Parameters
columnstringThe column.
valuestringThe value.
maxlongThe maximum.
customErrorMessageAccessorFunc<string, string, long, long, string>The custom error message accessor. The arguments are column, value, min, max.
ValueLengthValidator(string, string, long, long, Func<string, string, long, long, string>)
Initializes a new instance of the ValueLengthValidator class.
public ValueLengthValidator(string column, string value, long min, long max, Func<string, string, long, long, string> customErrorMessageAccessor = null)
Parameters
columnstringThe column.
valuestringThe value.
minlongThe minimum. Less than or equal to 0 means unlimited.
maxlongThe maximum. Less than or equal to 0 means unlimited.
customErrorMessageAccessorFunc<string, string, long, long, string>The custom error message accessor. The arguments are column, value, min, max.
Properties
CustomErrorMessage
Gets the custom error message.
protected override string CustomErrorMessage { get; }
Property Value
- string
The custom error message.
CustomErrorMessageAccessor
Gets the custom range message format.
public Func<string, string, long, long, string> CustomErrorMessageAccessor { get; set; }
Property Value
DefaultErrorMessage
Gets the default error message.
protected override string DefaultErrorMessage { get; }
Property Value
- string
The default error message.
HasCustomErrorMessage
Gets a value indicating whether this instance has custom error message.
protected override bool HasCustomErrorMessage { get; }
Property Value
- bool
trueif this instance has custom error message; otherwise,false.
MaxLength
Gets the maximum length.
public long MaxLength { get; }
Property Value
- long
The maximum length.
MinLength
Gets the minimum length.
public long MinLength { get; }
Property Value
- long
The minimum length.
Methods
ValidateValue()
Validates the value.
protected override bool ValidateValue()
Returns
- bool
The validation result.