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).isString().isValid
new Validator(69).isNumber().isRange(0, 100).isValid
new Validator('69')
.isNumber()
.call(validator => validator)
.throw(() => new TypeError('Value must be a number'))
Init
new Validator(value?)
Methods
setValue(value)
call(validator => validator)
throw(() => e)
isType(value?, type)
isObject(value?)
isUndefined(value?)
isBoolean(value?)
isNumber(value?)
isString(value?)
isFunction(value?)
isSymbol(value?)
isNull(value?)
isInstance(value?, instance)
isArray(value?)
isBuffer(value?)
isArrayBuffer(value?)
isRegExp(value?)
isSet(value?)
isMap(value?)
isPromise(value?)
isDate(value?)
isTimestamp(value?)
isUnixTimestamp(value?)
isError(value?)
isTypeError(value?)
isCodeError(value?)
isObjectExact(value?)
isTrue(value?)
isFalse(value?)
isExists(value?)
isNaN(value?)
isFinite(value?)
isInteger(value?)
isSafeInteger(value?)
isFloat(value?)
isInfinity(value?)
isMore(value?, number)
isLess(value?, number)
isEqual(value?, number)
isMoreEqual(value?, number)
isLessEqual(value?, number)
isRange(value?, min, max)
isPositive(value?)
isNegative(value?)
isRegex(value?, regex)
isRequired(value?)
isOptional(value?)
isLength(value?, length? || ...[min, max])
isEmpty(value?)
isHas(value?, key)
isIncludes(value?, value)
isIncluded(value?, array)
isUnique(value?)
isUUID(value?)
isIPv4(value?)
isUrl(value?)
isEmail(value?)
isPhoneNumber(value?)