🌊
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

ofClass

arrayOf :: String → a → Boolean

PreviousofUniqueItems [TD]NextoneOfValues [TD]

Last updated 5 years ago

Was this helpful?

Takes the name of a valid javascript class in form of string (for example: 'String', 'Date', 'BigInt', etc) then returns a new function reporting whether the received value is an instance of that class.

ofClass is the backbone of all the type validators:

isString.js
import ofClass from './ofClass';

/**
 * Evaluates whether the given value is of type string
 * @param value
 * @returns {boolean}
 */
const isString = ofClass('String');

export default isString;

ofClass rely on Object.prototype.toString to check on the received value type in order to avoid and encouraging a runtime strict type validation.

typeof weird behaviours