New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@darkwolf/validator

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/validator - npm Package Compare versions

Comparing version 6.6.6 to 6.6.7

2

package.json
{
"name": "@darkwolf/validator",
"version": "6.6.6",
"version": "6.6.7",
"description": "Validator",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -24,4 +24,3 @@ # Validator

## Methods
### call(validator => validator)
### validate(() => boolean, errorMessage || () => errorMessage)
### validate(() => boolean, errorMessage || validator => errorMessage)
### throw(validator => e)

@@ -34,3 +33,3 @@ ### isRequired()

### isType(value?, type)
### isTag(value?, tag)
### isClass(value?, name)
### isInstance(value?, constructor)

@@ -37,0 +36,0 @@ ### isUndefined(value?)

@@ -58,3 +58,3 @@ const CodeError = require('@darkwolf/code-error')

_getTag(value) {
_getClass(value) {
return Object.prototype.toString.call(value)

@@ -75,4 +75,4 @@ }

_isTag(value, tag) {
return this._isEqual(this._getTag(value), `[object ${tag}]`)
_isClass(value, name) {
return this._isEqual(this._getClass(value), `[object ${name}]`)
}

@@ -109,3 +109,3 @@

_isPlainObject(value) {
return this._isTag(value, 'Object')
return this._isClass(value, 'Object')
}

@@ -118,15 +118,15 @@

_isBoolean(value) {
return this._isType(value, 'boolean') || this._isTag(value, 'Boolean')
return this._isType(value, 'boolean') || this._isClass(value, 'Boolean')
}
_isNumber(value) {
return this._isType(value, 'number') || this._isTag(value, 'Number')
return this._isType(value, 'number') || this._isClass(value, 'Number')
}
_isString(value) {
return this._isType(value, 'string') || this._isTag(value, 'String')
return this._isType(value, 'string') || this._isClass(value, 'String')
}
_isSymbol(value) {
return this._isType(value, 'symbol') || this._isTag(value, 'Symbol')
return this._isType(value, 'symbol') || this._isClass(value, 'Symbol')
}

@@ -400,8 +400,2 @@

call(callback) {
if (!this._isFunction(callback)) throw errors.INVALID_CALLBACK
callback(this)
return this
}
validate(callback, errorMessage, ...args) {

@@ -416,4 +410,4 @@ if (!this._isFunction(callback)) throw errors.INVALID_CALLBACK

if (!isValid) {
if (this.generateMessages) {
const message = this._isFunction(errorMessage) ? errorMessage(this.value, ...args) : errorMessage
if (this.generateMessages && errorMessage) {
const message = this._isFunction(errorMessage) ? errorMessage(this, ...args) : errorMessage
this.error.message = this.error.message ? `${this.error.message}\n${message}` : message

@@ -460,19 +454,19 @@ }

isEqual(...args) {
return this.validate((...args) => this._isEqual(...args), (value1, value2) => `${this.name} must be equal to ${this._isString(value2) ? `"${value2}"` : value2}`, ...args)
return this.validate((...args) => this._isEqual(...args), (val, value) => `${this.name} must be equal to ${this._isString(value) ? `"${value}"` : value}`, ...args)
}
isStrictEqual(...args) {
return this.validate((...args) => this._isStrictEqual(...args), (value1, value2) => `${this.name} must be strictly equal to ${this._isString(value2) ? `"${value2}"` : value2}`, ...args)
return this.validate((...args) => this._isStrictEqual(...args), (val, value) => `${this.name} must be strictly equal to ${this._isString(value) ? `"${value}"` : value}`, ...args)
}
isType(...args) {
return this.validate((...args) => this._isType(...args), (value, type) => `${this.name} must be ${type}`, ...args)
return this.validate((...args) => this._isType(...args), (val, type) => `${this.name} must be ${type}`, ...args)
}
isTag(...args) {
return this.validate((...args) => this._isTag(...args), (value, tag) => `${this.name} must be ${tag}`, ...args)
isClass(...args) {
return this.validate((...args) => this._isClass(...args), (val, name) => `${this.name} must be ${name}`, ...args)
}
isInstance(...args) {
return this.validate((...args) => this._isInstance(...args), (value, constructor) => `${this.name} must be an instance of ${constructor.name}`, ...args)
return this.validate((...args) => this._isInstance(...args), (val, constructor) => `${this.name} must be an instance of ${constructor.name}`, ...args)
}

@@ -605,19 +599,19 @@

isMore(...args) {
return this.validate((...args) => this._isMore(...args), (value, number) => `${this.name} must be more than ${number}`, ...args)
return this.validate((...args) => this._isMore(...args), (val, number) => `${this.name} must be more than ${number}`, ...args)
}
isLess(...args) {
return this.validate((...args) => this._isLess(...args), (value, number) => `${this.name} must be less than ${number}`, ...args)
return this.validate((...args) => this._isLess(...args), (val, number) => `${this.name} must be less than ${number}`, ...args)
}
isMoreEqual(...args) {
return this.validate((...args) => this._isMoreEqual(...args), (value, number) => `${this.name} must be more than or equal to ${number}`, ...args)
return this.validate((...args) => this._isMoreEqual(...args), (val, number) => `${this.name} must be more than or equal to ${number}`, ...args)
}
isLessEqual(...args) {
return this.validate((...args) => this._isLessEqual(...args), (value, number) => `${this.name} must be less than or equal to ${number}`, ...args)
return this.validate((...args) => this._isLessEqual(...args), (val, number) => `${this.name} must be less than or equal to ${number}`, ...args)
}
isRange(...args) {
return this.validate((...args) => this._isRange(...args), (value, min, max) => `${this.name} must be between ${min} and ${max}`, ...args)
return this.validate((...args) => this._isRange(...args), (val, min, max) => `${this.name} must be between ${min} and ${max}`, ...args)
}

@@ -666,3 +660,3 @@

isLength(...args) {
return this.validate((...args) => this._isLength(...args), (value, ...args) => {
return this.validate((...args) => this._isLength(...args), (val, ...args) => {
if (args.length) {

@@ -682,3 +676,3 @@ if (args.length > 1) {

isSize(...args) {
return this.validate((...args) => this._isSize(...args), (value, ...args) => {
return this.validate((...args) => this._isSize(...args), (val, ...args) => {
if (args.length) {

@@ -702,11 +696,11 @@ if (args.length > 1) {

isHas(...args) {
return this.validate((...args) => this._isHas(...args), (value, key) => `${this.name} must have the key "${key}"`, ...args)
return this.validate((...args) => this._isHas(...args), (val, key) => `${this.name} must have the key "${key}"`, ...args)
}
isIncludes(...args) {
return this.validate((...args) => this._isIncludes(...args), (value1, value2) => `${this.name} must include ${this._isString(value2) ? `"${value2}"` : value2}`, ...args)
return this.validate((...args) => this._isIncludes(...args), (val, value) => `${this.name} must include ${this._isString(value) ? `"${value}"` : value}`, ...args)
}
isIncluded(...args) {
return this.validate((...args) => this._isIncluded(...args), (value1, value2) => `${this.name} must be ${value2.map(o => this._isString(o) ? `"${o}"` : o).join(', ')}`, ...args)
return this.validate((...args) => this._isIncluded(...args), (val, value) => `${this.name} must be ${value.map(o => this._isString(o) ? `"${o}"` : o).join(', ')}`, ...args)
}

@@ -713,0 +707,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc