isArrayLength
isArrayLength({ min, max })Verifies if provided Verificable represents an array with length (number of items) is 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 an array:
Verificable is not an array:{
type: "isArray",
path: [/* ... */]
}If provided Verificable is an array with number of items outside the range:
Verificable is an array with number of items outside the range:{
type: "isArrayLength",
path: [/* ... */],
min: /* provided min value */,
max: /* provided max value */,
}Examples:
Each of examples uses this import statement:
Non-array values (like string in this example) are not a valid array, and will fail with an isArray error:
isArray error:Array with number of items outside of requested range will fail with isArrayLength error:
isArrayLength error: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?