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.1.0 to 2.1.1

58

index.js

@@ -198,2 +198,13 @@ class Validator {

_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
}
_isIncludes(value1, value2) {

@@ -212,13 +223,2 @@ if (this._isArray(value1)) return value1.includes(value2)

_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) {

@@ -239,2 +239,18 @@ if (this._isObject(value)) {

_isUUID(value) {
return this._isRegex(value, /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/i)
}
_isUrl(value) {
return this._isRegex(value, /^(https?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3}))(\:\d+)?(\/[\w-.%+@&:~]*)*(\?[\w-.%+@&=:;,~]*)?(\#[\w-]*)?$/i)
}
_isEmail(value) {
return this._isRegex(value, /^[\w-.]+@(([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}$/i)
}
_isPhoneNumber(value) {
return this._isRegex(value, /^\+[1-9]\d{6,14}$/)
}
_valid(callback) {

@@ -474,4 +490,24 @@ if (!this._isOptional) {

}
isUUID(...args) {
if (args.length) return this._isUUID(...args)
return this._valid(() => this._isUUID(this.value))
}
isUrl(...args) {
if (args.length) return this._isUrl(...args)
return this._valid(() => this._isUrl(this.value))
}
isEmail(...args) {
if (args.length) return this._isEmail(...args)
return this._valid(() => this._isEmail(this.value))
}
isPhoneNumber(...args) {
if (args.length) return this._isPhoneNumber(...args)
return this._valid(() => this._isPhoneNumber(this.value))
}
}
module.exports = new Validator()

2

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

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

@@ -74,1 +74,5 @@ # Validator Utility

### isUnique(value?)
### isUUID(value?)
### isUrl(value?)
### isEmail(value?)
### isPhoneNumber(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