Pike v8.1 release 6

Method Standards.JSON.Validator()->validate_object()


Method validate_object

private string validate_object(string key, mixed value, mapping(string:mixed) schema)

Description

Verify that the specified value is an object according to the specified schema. The following properties of schema are verified:

minProperties

If schema has the property "minProperties", then the object must have at least the specified number of properties.

maxProperties

If schema has the property "maxProperties", then the object must not have more than the specified number of items.

required

If schema has the property "required", which is an array of strings, then the object must have all properties that are listed in the specified array.

properties

If schema has the property "properties", which is a mapping of property-name to a schema, then each property of the object that has a corresponding schema in "properties" must be valid according to that schema.

patternProperties

If schema has the property "properties", which is a mapping of property-name-pattern to a schema, then each property of the object must be valid according to all schema objects for which the pattern matches the property-name.

additionalProperties

If schema has the property "additionalProperties", it can be either a boolean value, or a schema.

  • If it is a boolean with value Standards.JSON.false, then all properties of the object must be validated either by a schema from "properties" or "patternProperties".

  • If it is a boolean with value Standards.JSON.true, then the object is allowed to have additional properties without validation.

  • If it is a schema, then any propery of the object that is not validated by a schema from "properties" or "patternProperties" must be validated by the specified schema.

Note

TODO: We use Regexp.SimpleRegexp to handle schema->patternProperties, but that covers only some part of the possible regular expressions.