Skip to content

Commit

Permalink
Mark an additionalProperty as evaluated.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmorgan committed Jun 7, 2024
1 parent 2fb11c6 commit adaf37d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
10 changes: 6 additions & 4 deletions lib/src/json_schema/validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -530,17 +530,19 @@ class Validator {
}
});

if (!propCovered) {
if (propCovered) {
_addEvaluatedProp(newInstance);
} else {
final additionalPropertiesSchema = schema.additionalPropertiesSchema;
if (additionalPropertiesSchema != null) {
_validate(additionalPropertiesSchema, newInstance);
_addEvaluatedProp(newInstance);
} else if (propMustValidate) {
_err('unallowed additional property $k', instance.path, '${schema.path!}/additionalProperties');
_err('unallowed additional property $k', instance.path,
'${schema.path!}/additionalProperties');
} else if (schema.additionalPropertiesBool == true) {
_addEvaluatedProp(newInstance);
}
} else {
_addEvaluatedProp(newInstance);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,5 +1307,22 @@
"valid": false
}
]
}
},
{
"description": "additionalProperties",
"schema": {
"type": "object",
"additionalProperties": {"type": "object"},
"unevaluatedProperties": false
},
"tests": [
{
"description": "are evaluated",
"data": {
"anyKey": {}
},
"valid": true
}
]
}
]
38 changes: 36 additions & 2 deletions test/unit/specification_tests.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit adaf37d

Please sign in to comment.