- Source:
Methods
(static) ge(value) → {Array.<any>|null}
Checks whether value is greater or equal than defined values
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns tuple ['number.ge', ge]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
const greaterEqual = number.ge(3)
console.log(greaterEqual(undefined)) // null
console.log(greaterEqual(null)) // null
console.log(greaterEqual(4)) // null
console.log(greaterEqual(3)) // null
console.log(greaterEqual(2)) // ['number.ge', 3]
(static) gt(value) → {Array.<any>|null}
Checks whether value is greater than defined values
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns tuple ['number.gt', gt]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
const greaterThan = number.gt(3)
console.log(greaterThan(undefined)) // null
console.log(greaterThan(null)) // null
console.log(greaterThan(4)) // null
console.log(greaterThan(3)) // ['number.gt', 3]
console.log(greaterThan(2)) // ['number.gt', 3]
(static) inRange(value) → {Array.<any>|null}
Checks whether value is in defined range
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns tuple ['number.range', [min, max]]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
const inRng = number.inRange([2, 5])
console.log(inRng(undefined)) // null
console.log(inRng(null)) // null
console.log(inRng(2)) // null
console.log(inRng(3)) // null
console.log(inRng(4)) // null
console.log(inRng(5)) // ['number.range', [2, 5]]
console.log(inRng(6)) // ['number.range', [2, 5]]
(static) isNumber(value) → {Array.<any>|null}
Checks whether value is number
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns ['number.type']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
console.log(number.isNumber(undefined)) // null
console.log(number.isNumber(null)) // null
console.log(number.isNumber(2)) // null
console.log(number.isNumber('5')) // ['number.type']
console.log(number.isNumber([])) // ['number.type']
(static) le(value) → {Array.<any>|null}
Checks whether value is lower or equal than defined values
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns tuple ['number.le', le]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
const lowerOrEqual = number.le(3)
console.log(lowerOrEqual(undefined)) // null
console.log(lowerOrEqual(null)) // null
console.log(lowerOrEqual(2)) // null
console.log(lowerOrEqual(3)) // null
console.log(lowerOrEqual(4)) // ['number.le', 3]
(static) lt(value) → {Array.<any>|null}
Checks whether value is lower than defined values
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts a number value |
Returns:
returns tuple ['number.lt', lt]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { number } = validators
const lowerThan = number.lt(3)
console.log(lowerThan(undefined)) // null
console.log(lowerThan(null)) // null
console.log(lowerThan(2)) // null
console.log(lowerThan(3)) // ['number.lt', 3]
console.log(lowerThan(4)) // ['number.lt', 3]