- Source:
Methods
(static) isAlphanum(value) → {Array.<any>|null}
Checks whether value contains only alphanumeric characters
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.alphanum']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isAlphanum(undefined)) // null
console.log(string.isAlphanum(null)) // null
console.log(string.isAlphanum('abcd')) // null
console.log(string.isAlphanum('abcd192')) // null
console.log(string.isAlphanum('12abcd192')) // null
console.log(string.isAlphanum('192')) // null
console.log(string.isAlphanum('email@address')) // ['string.alphanum']
console.log(string.isAlphanum('email@')) // ['string.alphanum']
(static) isDigits(value) → {Array.<any>|null}
Checks whether value contains only digits
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.digits']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isDigits(undefined)) // null
console.log(string.isDigits(null)) // null
console.log(string.isDigits('1991')) // null
console.log(string.isDigits('email@address')) // ['string.digits']
console.log(string.isDigits('email@')) // ['string.digits']
(static) isEmail(value) → {Array.<any>|null}
Checks whether value is valid email address
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.email']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isEmail(undefined)) // null
console.log(string.isEmail(null)) // null
console.log(string.isEmail('email@address.com')) // null
console.log(string.isEmail('email@address')) // ['string.email']
console.log(string.isEmail('email@')) // ['string.email']
(static) isISODate(value) → {Array.<any>|null}
Checks whether value is iso date string
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.iso.date']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isISODate(undefined)) // null
console.log(string.isISODate(null)) // null
console.log(string.isISODate('2018-05-01T09:31:21.156Z')) // null
console.log(string.isISODate('Tue May 01 2018 12:29:30 GMT+0300 (+03)')) // ['string.iso.date']
console.log(string.isISODate('email@')) // ['string.iso.date']
(static) isNotEmpty(value) → {Array.<any>|null}
Checks whether value is empty string
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.empty']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isNotEmpty(undefined)) // null
console.log(string.isNotEmpty(null)) // null
console.log(string.isNotEmpty('-\/-')) // null
console.log(string.isNotEmpty('')) // ['string.empty']
(static) isString(value) → {Array.<any>|null}
Checks whether value is string
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts any value |
Returns:
returns ['string.type']
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
console.log(string.isString(undefined)) // null
console.log(string.isString(null)) // null
console.log(string.isString('-\/-')) // null
console.log(string.isString('')) // null
console.log(string.isString({})) // ['string.type']
console.log(string.isString(1)) // ['string.type']
(static) length(value) → {Array.<any>|null}
Checks whether value has length equal expected size
Parameters:
Name | Type | Description |
---|---|---|
value |
number |
accepts exact length for a string |
Returns:
returns ['string.exact.length', length]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
const length = string.length(5)
console.log(length(undefined)) // null
console.log(length(null)) // null
console.log(length('Tommy')) // null
console.log(length('Todd')) // ['string.exact.length', 5]
console.log(length('Ronney')) // ['string.exact.length', 5]
(static) match(value) → {Array.<any>|null}
Checks whether value is match a specific pattern
Parameters:
Name | Type | Description |
---|---|---|
value |
any |
accepts string |
Returns:
returns ['string.match', pattern]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
const isUsername = string.match(/^[a-zA-Z\s]+$/)
console.log(isUsername(undefined)) // null
console.log(isUsername(null)) // null
console.log(isUsername('John Margin')) // null
console.log(isUsername('10292929')) // ['string.match']
console.log(isUsername('19 192 191.ds.')) // ['string.match']
console.log(isUsername('')) // ['string.match']
(static) maxLength(value) → {Array.<any>|null}
Checks whether value has length less or equal than expected max length
Parameters:
Name | Type | Description |
---|---|---|
value |
number |
accepts max length for a string |
Returns:
returns ['string.max.length', maxLength]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
const maxLength = string.maxLength(5)
console.log(maxLength(undefined)) // null
console.log(maxLength(null)) // null
console.log(maxLength('John')) // null
console.log(maxLength('Tommy')) // null
console.log(maxLength('Tom Martin')) // ['string.max.length', 5]
console.log(maxLength('Ronny Ronney')) // ['string.max.length', 5]
(static) minLength(value) → {Array.<any>|null}
Checks whether value has length greater or equal than expected min length
Parameters:
Name | Type | Description |
---|---|---|
value |
number |
accepts min length for a string |
Returns:
returns ['string.min.length', minLength]
- Type
- Array.<any> | null
- Source:
Example
import { validators } from 'egoist-js'
const { string } = validators
const minLength = string.minLength(5)
console.log(minLength(undefined)) // null
console.log(minLength(null)) // null
console.log(minLength('John Margin')) // null
console.log(minLength('Tommy')) // null
console.log(minLength('Tom')) // ['string.min.length', 5]
console.log(minLength('Jedi')) // ['string.min.length', 5]
console.log(minLength('')) // ['string.min.length', 5]