Make sure to include extraneous properties in the result value, when allowed

remotes/1723093605276550129/master
Sven Slootweg 5 years ago
parent a933fce273
commit c3812585b9

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

Loading…
Cancel
Save