🔍
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

Was this helpful?

  1. Functions

isValid

function isValid(verificable, predicate): boolean

This function assesses if the provided verificable matches or not the provided predicate .

Returns true if predicate is matched, false otherwise.

Examples:

First, let's define an example value that we want to verify and wrap it with asVerificable():

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

const value = 123.4;
const verificable = asVerificable(value);

Then we can use isValid() function to verify if provided value represented by verificable object matches our chosen predicates: isString, isNumber, isInteger, isNumberInRange():

isValid(verificable, isString); // false
isValid(verificable, isNumber); // true
isValid(verificable, isInteger); // false
isValid(verificable, isNumberInRange({ min: 100, max: 200 })); // true
PreviousasVerificableNextgetErrors

Last updated 5 years ago

Was this helpful?