Huge News!Announcing our $40M Series B led by Abstract Ventures.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 2.0.9 to 2.1.0

54

index.js

@@ -198,6 +198,41 @@ class Validator {

_isIncluded(value, array) {
return array.includes(value)
_isIncludes(value1, value2) {
if (this._isArray(value1)) return value1.includes(value2)
if (this._isSet(value1)) return value1.has(value2)
if (this._isMap(value1)) {
return Array.from(value1).some(([key, value]) => value === value2)
}
return false
}
_isIncluded(value1, value2) {
return this._isIncludes(value2, value1)
}
_isHas(value, key) {
if (this._isObject(value)) {
if (this._isArray(value) || this._isSet(value)) {
return this._isRange(key, 0, value.length || value.size)
}
if (this._isMap(value)) return value.has(key)
return value.hasOwnProperty(key)
}
return false
}
_isUnique(value) {
if (this._isObject(value)) {
if (this._isArray(value)) {
return this._isEqual(value.length, [...new Set(value)].length)
}
if (this._isSet(value)) return true
if (this._isMap(value)) {
return this._isEqual(value.size, [...new Set(Array.from(value))].length)
}
const values = Object.values(value)
return this._isEqual(values.length, [...new Set(values)].length)
}
return false
}
_valid(callback) {

@@ -418,2 +453,12 @@ if (!this._isOptional) {

isHas(...args) {
if (args.length > 1) return this._isHas(...args)
return this._valid(() => this._isHas(this.value, ...args))
}
isIncludes(...args) {
if (args.length > 1) return this._isIncludes(...args)
return this._valid(() => this._isIncludes(this.value, ...args))
}
isIncluded(...args) {

@@ -423,4 +468,9 @@ if (args.length > 1) return this._isIncluded(...args)

}
isUnique(...args) {
if (args.length) return this._isUnique(...args)
return this._valid(() => this._isUnique(this.value))
}
}
module.exports = new Validator()

2

package.json
{
"name": "@darkwolf/validator",
"version": "2.0.9",
"version": "2.1.0",
"description": "Validator Utility",

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

@@ -70,2 +70,5 @@ # Validator Utility

### isEmpty(value?)
### isHas(value?, key)
### isIncludes(value?, value)
### isIncluded(value?, array)
### isUnique(value?)
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