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 1.0.2 to 1.1.0

51

index.js
const CodeError = require('@darkwolf/code-error')
const errors = require('@darkwolf/errors')

@@ -11,2 +12,7 @@ class Validator {

this.isArray = this.isArray.bind(this)
this.isUsername = this.isUsername.bind(this)
this.isEmail = this.isEmail.bind(this)
this.isPhoneNumber = this.isPhoneNumber.bind(this)
this.isDarkwolfId = this.isDarkwolfId.bind(this)
this.isPassword = this.isPassword.bind(this)
}

@@ -66,2 +72,22 @@

isUsername(value) {
return /^(?!.*_{2,}.*)[a-z][a-z\d_]{3,30}[a-z\d]$/.test(value)
}
isEmail(value) {
return /^(?![^A-Z]*[A-Z])\S+@\S+\.\S+$/.test(value)
}
isPhoneNumber(value) {
return /^\+\d{5,15}$/.test(value)
}
isDarkwolfId(value) {
return this.isUsername(value) || this.isEmail(value) || this.isPhoneNumber(value)
}
isPassword(value) {
return /^(?=[^A-Z]*[A-Z])(?=[^a-z]*[a-z])(?=\D*\d)(?=[^!@#$%^&*]*[!@#$%^&*])[\w!@#$%^&*]{6,20}$/.test(value)
}
isValidBoolean(value, name, code, data) {

@@ -120,4 +146,29 @@ if (!this.isBoolean(value)) {

}
isValidUsername(value) {
if (!this.isUsername(value)) throw errors.INVALID_USERNAME
return true
}
isValidEmail(value) {
if (!this.isEmail(value)) throw errors.INVALID_EMAIL
return true
}
isValidPhoneNumber(value) {
if (!this.isPhoneNumber(value)) throw errors.INVALID_PHONE_NUMBER
return true
}
isValidDarkwolfId(value) {
if (!this.isDarkwolfId(value)) throw errors.INVALID_DARKWOLF_ID
return true
}
isValidPassword(value) {
if (!this.isPassword(value)) throw errors.INVALID_PASSWORD
return true
}
}
module.exports = new Validator()

5

package.json
{
"name": "@darkwolf/validator",
"version": "1.0.2",
"version": "1.1.0",
"description": "Validator",

@@ -23,4 +23,5 @@ "main": "index.js",

"dependencies": {
"@darkwolf/code-error": "^1.0.2"
"@darkwolf/code-error": "^1.0.2",
"@darkwolf/errors": "^1.1.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