isNumberInRange

isNumberInRange({ min, max })

Verifies if provided Verificable represents a finite number 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 type number

  • max - optional, of type number

Possible errors:

If provided Verificable is not a number:

{
    type: "isNumber",
    path: [/* ... */]
}

If provided Verificable is not a finite number:

{
    type: "isFiniteNumber",
    path: [/* ... */]
}

If provided Verificable is a number outside the range:

Examples:

Each of examples uses this import statement:

Null or undefined is not considered a number:

String value is not considered a number as well:

Not finite numbers will not match with isFiniteNumber error:

Any finite number outside of requested range will fail with isNumberInRange error:

Not providing min, max or both constrains will mean no requirement on those missing 'ends' of the range:

Last updated

Was this helpful?