Correctly deal with non-array rule specifications

remotes/1723093605276550129/master
Sven Slootweg 5 years ago
parent 5a1ece5482
commit 0dceef84e4

@ -2,6 +2,7 @@
const asExpression = require("as-expression");
const defaultValue = require("default-value");
const assureArray = require("assure-array");
const flatten = require("flatten");
const ValidationError = require("@validatem/error");
@ -15,7 +16,7 @@ function containsRules(rules) {
return false;
} else {
// TODO: Switch to `Array#flat` once Node 10.x goes EOL (April 2021)
let flattenedRules = flatten(rules);
let flattenedRules = flatten(assureArray(rules));
if (!flattenedRules.some((rule) => rule != null)) {
return false;

@ -17,6 +17,7 @@
"@validatem/error": "^1.0.0",
"@validatem/validation-result": "^0.1.1",
"as-expression": "^1.0.0",
"assure-array": "^1.0.0",
"default-value": "^1.0.0",
"flatten": "^1.0.3"
},

Loading…
Cancel
Save