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

Last updated