integer
An integer.
Signature
ts
function integer(msg?: Message): Action<number>Parameters
| Parameter | Type | Description |
|---|---|---|
msg | Message | Custom error message. A string with {params} or a function |
Error codes
| Code | When | Default message |
|---|---|---|
integer | Has a fractional part | Must be an integer |
You can change the texts: see Messages & i18n.
Notes
Checked with Number.isInteger: 5.0 is an integer, 5.5 is not.
Example
Page number
ts
optional(pipe(coerce.number(), integer(), min(1)), 1)