isStringLength
isStringLength({ min, max })Verifies if provided Verificable represents a string with length within specified range. Both min and max arguments are optional - not providing any of them means value on that 'end' will not be checked.
Arguments:
min- optional, of typenumbermax- optional, of typenumber
Possible errors:
If provided Verificable is not a string:
Verificable is not a string:{
type: "isString",
path: [/* ... */]
}If provided Verificable is a string with length being outside of the range:
Verificable is a string with length being outside of the range:{
type: "isStringLength",
path: [/* ... */],
min: /* provided min value */,
max: /* provided max value */,
}Examples:
Each of examples uses this import statement:
Non-string values will fail with an isString error:
isString error:String values with length outside of requested range will fail with isStringLength error:
isStringLength error:String values with length inside of requested range will match:
Not providing min, max or both constrains will mean no requirement on those missing 'ends' of the range:
min, max or both constrains will mean no requirement on those missing 'ends' of the range:Last updated
Was this helpful?