Skip to content

integer ​

An integer.

Signature ​

ts
function integer(msg?: Message): Action<number>

Parameters ​

ParameterTypeDescription
msgMessageCustom error message. A string with {params} or a function

Error codes ​

CodeWhenDefault message
integerHas a fractional partMust 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)

See also ​