validators/boolean

ego~ validators/boolean

Methods

(static) isBoolean(value) → {Array.<string>|null}

Parameters:
Name Type Description
value any

any possible value

Returns:

returns one item array with key ['boolean.type']

Type
Array.<string> | null
Source:
Example
import { validators } from 'egoist-js'

const { boolean } = validators

console.log(boolean.isBoolean(undefined)) // null
console.log(boolean.isBoolean(null)) // null
console.log(boolean.isBoolean(false)) // null
console.log(boolean.isBoolean(true)) // null

console.log(boolean.isBoolean(1)) // ['boolean.type']
console.log(boolean.isBoolean([])) // ['boolean.type']
console.log(boolean.isBoolean('')) // ['boolean.type']
console.log(boolean.isBoolean(0)) // ['boolean.type']

(static) isFalsy(value) → {Array.<string>|null}

Parameters:
Name Type Description
value any

any possible value

Returns:

returns one item array with key ['boolean.falsy']

Type
Array.<string> | null
Source:
Example
import { validators } from 'egoist-js'

const { boolean } = validators

console.log(boolean.isFalsy(undefined)) // null
console.log(boolean.isFalsy(null)) // null
console.log(boolean.isFalsy(false)) // null
console.log(boolean.isFalsy(NaN)) // null
console.log(boolean.isFalsy(0)) // null
console.log(boolean.isFalsy('')) // null

console.log(boolean.isFalsy(1)) // ['boolean.falsy']
console.log(boolean.isFalsy([])) // ['boolean.falsy']
console.log(boolean.isFalsy('string')) // ['boolean.falsy']

(static) isTruthy(value) → {Array.<string>|null}

Parameters:
Name Type Description
value any

any possible value

Returns:

returns one item array with key ['boolean.truthy']

Type
Array.<string> | null
Source:
Example
import { validators } from 'egoist-js'

const { boolean } = validators

console.log(boolean.isTruthy(1)) // null
console.log(boolean.isTruthy([])) // null
console.log(boolean.isTruthy('string')) // null

console.log(boolean.isTruthy(undefined)) // ['boolean.truthy']
console.log(boolean.isTruthy(null)) // ['boolean.truthy']
console.log(boolean.isTruthy(false)) // ['boolean.truthy']
console.log(boolean.isTruthy(NaN)) // ['boolean.truthy']
console.log(boolean.isTruthy(0)) // ['boolean.truthy']
console.log(boolean.isTruthy('')) // ['boolean.truthy']