Subject: | Feature request - Strict mode |
Would it be possible to pass an option "strict" that would then raise an error on unknown properties passed in the data. Take the following example that I would expect to fail with an error specifying that "thing" is an unknown property/key.
my $schema = '{
"$schema" : "http://json-schema.org/draft-07/schema#",
"$id" : "https://example.com/arrays.schema.json",
"title" : "The Root Schema",
"description" : "A representation of a person, company, organization, or place",
"type" : "object",
"examples" : [
{
"id" : 1,
"checked" : false
}
],
"required" : [
"checked",
"id"
],
"properties" : {
"checked" : {
"$id" : "#/properties/checked",
"title" : "The Checked Schema",
"description" : "An explanation about the purpose of this instance.",
"type" : "boolean",
"examples" : [
true,
false
]
},
"id" : {
"$id" : "#/properties/id",
"title" : "The ID of the door",
"description" : "This section represents the id of the door.",
"type" : "integer",
"examples" : [
1
]
}
}
}';
my $data = '{
"checked": false,
"id": 1,
"thing": "not okay"
}';
my $validator = JSON::Schema->new($schema, strict => 1);
my $result = $validator->validate($data); # errors