@darkwolf/validator
Advanced tools
Comparing version 2.1.2 to 2.1.3
29
index.js
@@ -176,2 +176,10 @@ const CodeError = require('@darkwolf/code-error') | ||
_isPositive(value) { | ||
return this._isMore(value, 0) | ||
} | ||
_isNegative(value) { | ||
return this._isLess(value, 0) | ||
} | ||
_isTrue(value) { | ||
@@ -256,4 +264,8 @@ return this._isEqual(value, true) | ||
_isIPv4(value) { | ||
return this._isRegex(value, /^((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/) | ||
} | ||
_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) | ||
return this._isRegex(value, /^(https?:\/\/)?((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]))(:\d+)?(\/[\w-.%+@&:~]*)*(\?[\w-.%+@&=:;,~]*)?(#[\w-]*)?$/i) | ||
} | ||
@@ -463,2 +475,12 @@ | ||
isPositive(...args) { | ||
if (args.length) return this._isPositive(...args) | ||
return this._valid(() => this._isPositive(this.value)) | ||
} | ||
isNegative(...args) { | ||
if (args.length) return this._isNegative(...args) | ||
return this._valid(() => this._isNegative(this.value)) | ||
} | ||
isTrue(...args) { | ||
@@ -525,2 +547,7 @@ if (args.length) return this._isTrue(...args) | ||
isIPv4(...args) { | ||
if (args.length) return this._isIPv4(...args) | ||
return this._valid(() => this._isIPv4(this.value)) | ||
} | ||
isUrl(...args) { | ||
@@ -527,0 +554,0 @@ if (args.length) return this._isUrl(...args) |
{ | ||
"name": "@darkwolf/validator", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Validator Utility", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -68,2 +68,4 @@ # Validator Utility | ||
### isRange(value?, min, max) | ||
### isPositive(value?) | ||
### isNegative(value?) | ||
### isRegex(value?, regex) | ||
@@ -79,4 +81,5 @@ ### isRequired(value?) | ||
### isUUID(value?) | ||
### isIPv4(value?) | ||
### isUrl(value?) | ||
### isEmail(value?) | ||
### isPhoneNumber(value?) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18115
449
84