validate#

scikitplot.agent.validate(schema, instance)[source]#

Return the reasons instance does not match schema.

Parameters:
schemamapping

A schema accepted by check_schema.

instanceobject

A plain JSON value.

Returns:
list of str

Empty when the instance matches. Each reason starts with the JSON Pointer of the value it is about (/query, /ids/2); at most MAX_REPORTED are listed, then how many more there were.

Parameters:
Return type:

list[str]

Examples

>>> from scikitplot.agent._schema import validate
>>> schema = {
...     "type": "object",
...     "properties": {"k": {"type": "integer", "minimum": 1}},
...     "required": ["k"],
...     "additionalProperties": False,
... }
>>> validate(schema, {"k": 3})
[]
>>> validate(schema, {"k": 0, "x": 1})
['/k: 0 is less than the minimum 1', "/: property 'x' is not allowed"]