isInteger

isInteger

Verifies if provided Verificable represents a number that is an integer. Integer values are values with the part after decimal point being 0.

The check internally is done by calling the JS function Number.isInteger().

Possible errors:

If provided Verificable is not a number:

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

If provided Verificable is not a integer:

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

Examples:

Each of examples uses this import statement:

const { asVerificable, isValid, isInteger } = require("verifica");

Null or undefined is not considered a number:

String value is not considered a number as well:

Infinity, -Infinity, or NaN are not considered integers:

Numbers with non-zero decimal part are not considered integers:

Numbers with decimal part equal to zero are considered integers:

Last updated

Was this helpful?