@toolz/allow
Advanced tools
Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "@toolz/allow", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Provides validation of data types", | ||
@@ -23,3 +23,3 @@ "keywords": [ | ||
"start": "node --experimental-modules --es-module-specifier-resolution=node src/allow.js", | ||
"test": "jest" | ||
"test": "jest --transformIgnorePatterns \"node_modules/(?!@toolz/allow)/\" --env=jsdom" | ||
}, | ||
@@ -38,7 +38,13 @@ "repository": { | ||
"devDependencies": { | ||
"@babel/core": "^7.11.1", | ||
"@babel/cli": "^7.13.0", | ||
"@babel/core": "^7.13.1", | ||
"@babel/node": "^7.10.5", | ||
"@babel/plugin-transform-modules-commonjs": "^7.13.0", | ||
"@babel/preset-env": "^7.11.0", | ||
"@babel/preset-react": "^7.12.13", | ||
"babel-jest": "^26.6.3", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-preset-jest": "^26.6.2", | ||
"jest": "^26.6.3", | ||
"jest-cli": "^26.6.3", | ||
"jest-matcher-one-of": "^1.0.2", | ||
@@ -52,3 +58,6 @@ "nodemon": "^2.0.4" | ||
"last 1 ie version" | ||
] | ||
], | ||
"dependencies": { | ||
"@toolz/is-a-regular-object": "^1.0.1" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import { isARegularObject } from '@toolz/is-a-regular-object'; | ||
const Allow = () => { | ||
@@ -94,5 +96,5 @@ let allowNull = false; | ||
const modelValue = modelObject[modelKey]; | ||
const isSuppliedValueAnObject = isAnObject(suppliedValue); | ||
const isSuppliedValueAnObject = isARegularObject(suppliedValue); | ||
const isSuppliedValueAnArray = Array.isArray(suppliedValue); | ||
const isModelValueAnObject = isAnObject(modelValue); | ||
const isModelValueAnObject = isARegularObject(modelValue); | ||
const isModelValueAnArray = Array.isArray(modelValue); | ||
@@ -119,3 +121,3 @@ if (isSuppliedValueAnObject !== isModelValueAnObject || isSuppliedValueAnArray !== isModelValueAnArray) | ||
anInteger(minNumberOfKeys, is.not.negative).anInteger(maxNumberOfKeys, is.not.negative); | ||
if (!isAnObject(value)) | ||
if (!isARegularObject(value)) | ||
return fail(value, 'is not an object'); | ||
@@ -181,8 +183,6 @@ checkLength(Object.keys(value), minNumberOfKeys, maxNumberOfKeys); | ||
const isAnObject = value => typeof value === 'object' && !Array.isArray(value) && value !== null; | ||
const oneOf = (value, allowedValues) => { | ||
if (allowNull && value === null) | ||
return allow; | ||
if (isAnObject(value) || Array.isArray(value) || typeof value === 'function') { | ||
if (isARegularObject(value) || Array.isArray(value) || typeof value === 'function') { | ||
fail(value, 'cannot be an object, array, or function'); | ||
@@ -221,2 +221,3 @@ return allow; | ||
return { | ||
@@ -223,0 +224,0 @@ aBoolean, |
82807
1133
1
13
+ Added@toolz/is-a-regular-object@1.0.2(transitive)