length
The length
validator combines the minLength
and maxLength
validators to check that the length of a string value is within a range. Both the minLength
and maxLength
values are inclusive.
If the value being validated is null
or an empty string, then the result will be valid. This respects the rule of thumb described in the notes for the required validator.
Named Props
minLength
: The minimum value compared againstmaxLength
: The maximum value compared against
Parameters
The length
validator supports three parameter signatures:
length(minLength, maxLength)
where theminLength
andmaxLength
named props are specified as valueslength(propsObject)
where the props object containsminLength
andmaxLength
named propslength(propsFunction)
where the props function returns a props object withminLength
andmaxLength
named props
Usage
Last updated
Was this helpful?