Validator Utility
Install
npm i --save @darkwolf/validator
Usage
const validator = require('@darkwolf/validator')
validator.isNumber(13)
validator.isString(21)
const { Validator } = validator
new Validator(69).isNumber().isString().isValid
new Validator(69).isNumber().or.isString().isValid
new Validator('69')
.isNumber()
.call(validator => validator.isString())
.throw(new TypeError('Value must be a number'))
Init
new Validator(value)
Methods
setValue(value)
and
or
call(callback(validator))
throw(e)
isType(value?, type)
isNotType(value?, type)
isBoolean(value?)
isNotBoolean(value?)
isNumber(value?)
isNotNumber(value?)
isString(value?)
isNotString(value?)
isObject(value?)
isNotObject(value?)
isFunction(value?)
isNotFunction(value?)
isUndefined(value?)
isNotUndefined(value?)
isNull(value?)
isNotNull(value?)
isInstance(value?, instance)
isNotInstance(value?, instance)
isArray(value?)
isNotArray(value?)
isBuffer(value?)
isNotBuffer(value?)
isArrayBuffer(value?)
isNotArrayBuffer(value?)
isExists(value?)
isNotExists(value?)
isNaN(value?)
isNotNaN(value?)
isFinite(value?)
isNotFinite(value?)
isInfinity(value?)
isNotInfinity(value?)
isRegExp(value?)
isNotRegExp(value?)
isSet(value?)
isNotSet(value?)