Extends
Methods
integer()
Require a number to be an integer.
Examples
const schema = vdn.number().integer()
vdn.attempt(5, schema) // Result == 5 (valid)
vdn.attempt(5.3, schema) // Throws ValidationError
Using data:
const schema = {
type: 'number',
integer: true
}
max(value)
Set the maximum value allowed.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The maximum value allowed. |
Examples
const schema = vdn.number().max(42)
vdn.attempt(42, schema) // Result == 42 (valid)
vdn.attempt(43, schema) // Throws ValidationError
Using data:
const schema = {
type: 'number',
max: 42
}
min(value)
Set the minimum value allowed.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The minimum value allowed. |