🌊
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

between

between :: Number → Number → a → Boolean

PreviousarrayOfShapeNextbiggerThan

Last updated 5 years ago

Was this helpful?

Takes a two numbers, min and max, and return a new function evaluating whether the received value is of included between min and max. (the one previously defined). The evaluation is not inclusive.

The between validator is a function

import between from 'deep-waters/between';

const isTeen = between(10)(19);

isTeen(17) // → true
isTeen(22); // → false
isTeen(7); // → false

Please note, between returned functions does not evaluate if the received values are of type integer or float. A good improvement for the isTeen validator from the example above could be the following:

import compose from 'deep-waters/compose';
import between from 'deep-waters/between';

const isTeen = compose(Number.isInteger, between(10)(19));

Related validators

curried
isNumber
biggerThan
smallerThan