Skip to content

Commit 37c2999

Browse files
committed
fix: Proper support for patternProperties used with unknownProperties
1 parent 8b0a1d6 commit 37c2999

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/revalidator.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,9 @@
354354

355355
// deleteUnknownProperties
356356
if (options.deleteUnknownProperties) {
357-
props = schema.properties ? Object.keys(schema.properties) : [];
358-
props = props.concat(schema.patternProperties ? Object.keys(schema.patternProperties) : []);
359357
for (p in object) {
360358
if (object.hasOwnProperty(p)) {
361-
if (props.indexOf(p) === -1) {
359+
if (visitedProps.indexOf(p) === -1) {
362360
delete object[p];
363361
}
364362
}
@@ -367,11 +365,9 @@
367365

368366
// unknownProperties
369367
if (options.unknownProperties) {
370-
props = schema.properties ? Object.keys(schema.properties) : [];
371-
props = props.concat(schema.patternProperties ? Object.keys(schema.patternProperties) : []);
372368
for (p in object) {
373369
if (object.hasOwnProperty(p)) {
374-
if (props.indexOf(p) === -1) {
370+
if (visitedProps.indexOf(p) === -1) {
375371
if (options.unknownProperties === 'delete') {
376372
delete object[p];
377373
} else if (options.unknownProperties === 'error') {

0 commit comments

Comments
 (0)