🔍
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. Getting started
  2. 🧑‍🎓 Examples

🧑‍🎓 Multiple conditions

If you need to check value for multiple conditions at once, you can use the all() function that allows you to combine multiple Predicates into single one:

const { asVerificable, all, isInteger, isNumberInRange, ensure } = require("verifica");

function sayAge(age) {
    const vage = asVerificable(age);
    
    const isValidAge = all(
        isInteger,
        isNumberInRange({ min: 0, max: 120 }),
    );
    
    ensure(vage, isValidAge);
    console.log(`You are ${age} years old!`);
}
Previous🧑‍🎓 BasicNext🧑‍🎓 Optional

Last updated 5 years ago

Was this helpful?