Compare commits

..

No commits in common. 'master' and 'master' have entirely different histories.

@ -3,6 +3,7 @@
const assureArray = require("assure-array");
const isPlainObj = require("is-plain-obj");
const defaultValue = require("default-value");
const flatten = require("flatten");
const matchSpecial = require("@validatem/match-special");
const isPlainObjectValidator = require("@validatem/is-plain-object");
@ -13,7 +14,8 @@ const hasShape = require("@validatem/has-shape");
module.exports = function normalizeRules(rules, options) {
let normalizeObjects = defaultValue(options.normalizeObjects, false);
let flattened = assureArray(rules).flat();
// TODO: Switch to `Array#flat` once Node 10.x goes EOL (April 2021)
let flattened = flatten(assureArray(rules));
let actualRules = flattened.filter((rule) => rule != null);
if (normalizeObjects) {
@ -32,7 +34,7 @@ module.exports = function normalizeRules(rules, options) {
}
});
return mapped.flat();
return flatten(mapped);
} else {
return actualRules;
}

@ -12,6 +12,7 @@
"@validatem/match-special": "^0.1.0",
"assure-array": "^1.0.0",
"default-value": "^1.0.0",
"flatten": "^1.0.3",
"is-plain-obj": "^2.1.0"
},
"devDependencies": {

@ -513,6 +513,11 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
flatten@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.3.tgz#c1283ac9f27b368abc1e36d1ff7b04501a30356b"
integrity sha512-dVsPA/UwQ8+2uoFe5GHtiBMu48dWLTdsuEd7CKGlZlD78r1TTWBvDuFaFGKCo/ZfEr95Uk56vZoX86OsHkUeIg==
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"

Loading…
Cancel
Save