🔍
verifica
  • Verifica
  • Getting started
    • 📦Installation
    • 🧑‍🎓 Examples
      • 🧑‍🎓 Basic
      • 🧑‍🎓 Multiple conditions
      • 🧑‍🎓 Optional
      • 🧑‍🎓 Custom rules
      • 🧑‍🎓 With express.js
    • 🟦Typescript
  • Functions
    • asVerificable
    • isValid
    • getErrors
    • ensure
    • rawValue
  • Predicates
    • Built-in Predicates
      • isArray
      • isArrayLength
      • isArrayOf
      • isBoolean
      • isFiniteNumber
      • isInteger
      • isNumber
      • isNumberInRange
      • isObject
      • isOneOf
      • isRegexMatch
      • isString
      • isStringLength
    • Operations on Predicates
      • all
      • optional
    • Custom Predicates
Powered by GitBook
On this page
  • Possible errors:
  • Examples:

Was this helpful?

  1. Predicates
  2. Built-in Predicates

isFiniteNumber

isFiniteNumber

Verifies if provided Verificable represents a number that is a finite value. Number values like Infinity, -Infinity, NaN, since not a finite values, will not match this Predicate.

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

Possible errors:

If provided Verificable is not a number:

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

If provided Verificable is not a finite number:

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

Examples:

Each of examples uses this import statement:

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

Null or undefined is not considered a number:

const verificable = asVerificable(null);
isValid(verificable, isFiniteNumber); // false

String value is not considered a number as well:

const verificable = asVerificable("123");
isValid(verificable, isFiniteNumber); // false

Infinity, -Infinity, or NaN are not considered finite numbers:

const verificable = asVerificable(Infinity);
isValid(verificable, isFiniteNumber); // false

Other numbers are considered finite numbers:

const verificable = asVerificable(12345.67);
isValid(verificable, isFiniteNumber); // true
PreviousisBooleanNextisInteger

Last updated 5 years ago

Was this helpful?