@toolz/allow
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "@toolz/allow", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Provides validation of data types", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -8,2 +8,4 @@ # allow | ||
**NOTE:** This library is designed for "vanilla" JS. If you are working in a React project, it's recommended to consider using `@toolz/allow-react`, which offers special behavior for evaluating React elements. | ||
## Usage | ||
@@ -28,3 +30,3 @@ | ||
In the above example, the assumption is that `originalPrice`should _always_ be a number. If any other data type is provided for `originalPrice`, the `allow`check will fail. This means that a value of `'32.99'`will fail (because it's a string). `null`will fail. Boolean values will fail. Anything that is _not_ a number will fail. In this example, the second argument (which is optional), indicates the minimum acceptable value of the number. In this case, we don't want negative values for `originalPrice`, so nothing below `0`will pass the check. | ||
In the above example, the assumption is that `originalPrice` should _always_ be a number. If any other data type is provided for `originalPrice`, the `allow`check will fail. This means that a value of `'32.99'`will fail (because it's a string). `null`will fail. Boolean values will fail. Anything that is _not_ a number will fail. In this example, the second argument (which is optional), indicates the minimum acceptable value of the number. In this case, we don't want negative values for `originalPrice`, so nothing below `0`will pass the check. | ||
@@ -31,0 +33,0 @@ ## Methods |
@@ -118,3 +118,3 @@ const Allow = () => { | ||
anInteger(minNumberOfKeys, is.not.negative).anInteger(maxNumberOfKeys, is.not.negative); | ||
if ((typeof value !== 'object' || Array.isArray(value) || value === null)) | ||
if (!isAnObject(value)) | ||
return fail(value, 'is not an object'); | ||
@@ -121,0 +121,0 @@ checkLength(Object.keys(value), minNumberOfKeys, maxNumberOfKeys); |
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
82526
666