Compare commits

...

2 Commits

@ -54,18 +54,23 @@ module.exports = function hasShape(rules) {
let errors = [];
let newObject = {};
for (let [ key, rule ] of Object.entries(rules)) {
let value = object[key];
for (let [ key, value ] of Object.entries(object)) {
let rule = rules[key];
let { errors: keyErrors, newValue } = applyValidators(value, rule);
if (rule != null) {
let { errors: keyErrors, newValue } = applyValidators(value, rule);
let annotatedErrors = annotateErrors({
pathSegments: [ key ],
errors: keyErrors
});
let annotatedErrors = annotateErrors({
pathSegments: [ key ],
errors: keyErrors
});
errors.push(... annotatedErrors);
newObject[key] = newValue;
errors.push(... annotatedErrors);
newObject[key] = newValue;
} else {
// Extraneous property
newObject[key] = value;
}
}
return validationResult({

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

Loading…
Cancel
Save