Compare commits

...

2 Commits

@ -5,7 +5,8 @@ const { validateValue } = require("@validatem/core");
const isString = require("@validatem/is-string"); const isString = require("@validatem/is-string");
let validator = hasShape({ let validator = hasShape({
foo: [ isString ] foo: [ isString ],
unused: [ isString ]
}); });
let objectA = { let objectA = {

@ -75,7 +75,11 @@ module.exports = function hasShape(rules) {
}); });
errors.push(... annotatedErrors); errors.push(... annotatedErrors);
newObject[key] = newValue;
// Don't scatter explicit `undefined`s across the result object, just because an optional rule existed for some properties but the corresponding value didn't
if (newValue !== undefined) {
newObject[key] = newValue;
}
} else { } else {
// Extraneous property // Extraneous property
newObject[key] = value; newObject[key] = value;

@ -6,7 +6,7 @@
"validator", "validator",
"combinator" "combinator"
], ],
"version": "0.1.6", "version": "0.1.7",
"main": "index.js", "main": "index.js",
"repository": "http://git.cryto.net/validatem/has-shape.git", "repository": "http://git.cryto.net/validatem/has-shape.git",
"author": "Sven Slootweg <admin@cryto.net>", "author": "Sven Slootweg <admin@cryto.net>",

Loading…
Cancel
Save