Skip to content
This repository was archived by the owner on Nov 2, 2023. It is now read-only.

Commit 6acf3a9

Browse files
committed
filter-helper
1 parent 8cd7a08 commit 6acf3a9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/validate.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,13 @@ var validate = exports._validate = function(/*Any*/instance,/*Object*/schema,/*O
209209
}
210210
for(i in instance){
211211
if(instance.hasOwnProperty(i) && !(i.charAt(0) == '_' && i.charAt(1) == '_') && objTypeDef && !objTypeDef[i] && additionalProp===false){
212-
errors.push({property:path,message:(typeof value) + "The property " + i +
212+
if (options.filter) {
213+
delete instance[i];
214+
continue;
215+
} else {
216+
errors.push({property:path,message:(typeof value) + "The property " + i +
213217
" is not defined in the schema and the schema does not allow additional properties"});
218+
}
214219
}
215220
var requires = objTypeDef && objTypeDef[i] && objTypeDef[i].requires;
216221
if(requires && !(requires in instance)){

0 commit comments

Comments
 (0)