@darkwolf/validator
Advanced tools
Comparing version 13.21.76 to 13.21.77
34
index.js
@@ -56,3 +56,11 @@ const CodeError = require('@darkwolf/code-error') | ||
const isNonPositive = value => isLessEqual(value, 0) | ||
const isNatural = value => isInteger(value) && isPositive(value) | ||
const isPositiveInteger = value => isInteger(value) && isPositive(value) | ||
const isPositiveFloat = value => isFloat(value) && isPositive(value) | ||
const isNegativeInteger = value => isInteger(value) && isNegative(value) | ||
const isNegativeFloat = value => isFloat(value) && isNegative(value) | ||
const isNonNegativeInteger = value => isInteger(value) && isNonNegative(value) | ||
const isNonNegativeFloat = value => isFloat(value) && isNonNegative(value) | ||
const isNonPositiveInteger = value => isInteger(value) && isNonPositive(value) | ||
const isNonPositiveFloat = value => isInteger(value) && isNonPositive(value) | ||
const isNatural = value => isNonNegativeInteger(value) | ||
const isEven = value => isInteger(value) && !(value % 2) | ||
@@ -75,2 +83,10 @@ const isOdd = value => isInteger(value) && !!(value % 2) | ||
if (args.length > 1) return isRange(length, ...args) | ||
const [options] = args | ||
if (isPlainObject(options)) { | ||
const {min, max} = options | ||
if (options.hasOwnProperty('min') && options.hasOwnProperty('max')) return isRange(length, min, max) | ||
if (options.hasOwnProperty('min')) return isMoreEqual(length, min) | ||
if (options.hasOwnProperty('max')) return isLessEqual(length, max) | ||
return false | ||
} | ||
return isStrictEqual(length, ...args) | ||
@@ -88,2 +104,10 @@ } | ||
if (args.length > 1) return isRange(size, ...args) | ||
const [options] = args | ||
if (isPlainObject(options)) { | ||
const {min, max} = options | ||
if (options.hasOwnProperty('min') && options.hasOwnProperty('max')) return isRange(size, min, max) | ||
if (options.hasOwnProperty('min')) return isMoreEqual(size, min) | ||
if (options.hasOwnProperty('max')) return isLessEqual(size, max) | ||
return false | ||
} | ||
return isStrictEqual(size, ...args) | ||
@@ -203,2 +227,10 @@ } | ||
isNonPositive, | ||
isPositiveInteger, | ||
isPositiveFloat, | ||
isNegativeInteger, | ||
isNegativeFloat, | ||
isNonNegativeInteger, | ||
isNonNegativeFloat, | ||
isNonPositiveInteger, | ||
isNonPositiveFloat, | ||
isNatural, | ||
@@ -205,0 +237,0 @@ isEven, |
{ | ||
"name": "@darkwolf/validator", | ||
"version": "13.21.76", | ||
"version": "13.21.77", | ||
"description": "Validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,2 +58,10 @@ # Validator | ||
### isNonPositive(value) | ||
### isPositiveInteger(value) | ||
### isPositiveFloat(value) | ||
### isNegativeInteger(value) | ||
### isNegativeFloat(value) | ||
### isNonNegativeInteger(value) | ||
### isNonNegativeFloat(value) | ||
### isNonPositiveInteger(value) | ||
### isNonPositiveFloat(value) | ||
### isNatural(value) | ||
@@ -71,4 +79,4 @@ ### isEven(value) | ||
### isKey(value) | ||
### isLength(value, number || ...[min, max]) | ||
### isSize(value, number || ...[min, max]) | ||
### isLength(value, number || ...[min, max] || options[min, max]) | ||
### isSize(value, number || ...[min, max] || options[min, max]) | ||
### isEmpty(value) | ||
@@ -75,0 +83,0 @@ ### isHas(value, key) |
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
16458
312
114