The rule is that for an object, the value of a property with name "xx"
must match a schema set defined as follows (and yes, I've had
difficulty understanding that at first):
* if "xx" is strictly equal to an entry in "properties", then its
value must obey the associated schema;
* if "patternProperties" exists, then the value of "xx" must also
match any schema for which "xx" matches one of "patternProperties"
(and note that "matches" here means matching in the **real** regex
sense: regex "p" matches "p", "ape", "proctor" and "mishap" -- if you
want your regex anchored, make it anchored);
* if AND ONLY IF the set of schemas is empty at this point, then "xx"
must match the schema associated with "additionalProperties" (if not
present, an empty schema).
It should be noted that:
* if additionalProperties is false, if the schema set is empty after
step 2, it means the JSON document is invalid: "xx" could not satisfy
any of "properties" or "patternProperties";
* if "xx" matches an entry in "properties", it DOES NOT prevent it to
have to consider patternProperties if present.
--
Francis Galiegue, fgal...@gmail.com
"It seems obvious [...] that at least some 'business intelligence'
tools invest so much intelligence on the business side that they have
nothing left for generating SQL queries" (Stéphane Faroult, in "The
Art of SQL", ISBN 0-596-00894-5)
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To post to this group, send email to json-...@googlegroups.com.
To unsubscribe from this group, send email to json-schema...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/json-schema?hl=en.
--
You received this message because you are subscribed to the Google Groups "JSON Schema" group.
To view this discussion on the web visit https://groups.google.com/d/msg/json-schema/-/7jTT9BCkdrcJ.
You should note that defining properties is NOT compulsory. You can
just define patternProperties and additionalProperties alone.
If I can give you an advice, when you encounter an object type and it
is allowed at this point, it is first to validate the object structure
(ie, the set of keys) before validating the values. If you have { "a":
2 }, you know it cannot validate since "^[0-9]+$" doesn't match "a".
(also, ECMA 262 supports \d, which is shorter than [0-9])