🌊
Deep Waters
  • What is Deep Waters
  • 📌Getting started
    • Installation
  • 🍰Composition
    • compose
    • when
    • or
    • not
  • 👁️ Validators
    • arrayOf
    • arrayOfShape
    • between
    • biggerThan
    • contains
    • equals
    • every
    • hasProp
    • hasShape
    • isCreditCard
      • isVISA
      • isMastercard
      • isAmericanExpress
      • isDinersClub
      • isDiscover
      • isJCB
    • isDateFormat [TD]
    • isDivisibleBy [TD]
    • isEmail [TD]
    • isEmpty [TD]
    • isEmptyString [TD]
    • isIP [TD]
      • isIPv6 [TD]
      • isIPv4 [TD]
    • isNumeric [TD]
    • isPhone [TD]
    • isPrimitive [TD]
    • isRequired [TD]
    • isURL [TD]
    • matchesPattern [TD]
    • maxLenght [TD]
    • minLength [TD]
    • ofLength [TD]
    • ofUniqueItems [TD]
    • ofClass
    • oneOfValues [TD]
    • smallerThan
  • ✅Type validators
    • isBigInt
    • isBoolean
    • isBuffer
    • isDate
    • isError
    • isFunction
    • isInt8Array
    • isMap
    • isNull
    • isNumber
    • isObject
    • isRegExp
    • isSet
    • isString
    • isSymbol
    • isUint8Array
    • isUndefined
    • isWeakMap
    • isWeakSet
  • github repository
Powered by GitBook
On this page

Was this helpful?

  1. 👁️ Validators

every

every :: Function → [ a ] → Boolean

Takes a validator and returns a new function that makes sure the received array matches the defined validator for each one if its elements.

import arrayOf from 'deep-waters/arrayOf';
import isNumber from 'deep-waters/isNumber';
import isString from 'deep-waters/isString';

// array of numbers only
const arrayOfNumbers = arrayOf(isNumber); 

arrayOfNumbers([1, 2, 3, 4]); // → true;
arrayOfNumbers(['s', 't,' 'r', 'i', 'n', 'g']); // → false;

// array of multiple types
const numAndStrings = arrayOf(or(isNumber, isString));

numAndStrings([1, 2, 3, 4, 'can I have a little more?']); // → true;

PreviousequalsNexthasProp

Last updated 5 years ago

Was this helpful?