1 row in set (0.00 sec) 

Now we set @document  such that it specifies an illegal value for one of its properties, like this: 

mysql> SET @document = ’{ ’> "latitude": 63.444697, ’> "longitude": 310.445118 ’> }’; 

Validation of @document  now fails when tested with JSON_SCHEMA_VALIDATION_REPORT() . The output from the function call contains detailed information about the failure (with the function wrapped by JSON_PRETTY()  to provide better formatting), as shown here: 

mysql> SELECT JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document))\G *************************** 1. row *************************** JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document)): { "valid": false, "reason": "schema-location": "#/properties/longitude", "document-location": "#/longitude", "schema-failed-keyword": "maximum" } 1 row in set (0.00 sec) 

Since @schema  contains the required  attribute, we can set @document  to a value that is otherwise valid but does not contain the required properties, then test it against @schema . The output of JSON_SCHEMA_VALIDATION_REPORT()  shows that validation fails due to lack of a required element, like this: 

mysql> SET @document = ’{}’; Query OK, 0 rows affected (0.00 sec) mysql> SELECT JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document))\G *************************** 1. row *************************** JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document)): { "valid": false, "reason": "The JSON document location ’#’ failed requirement ’required’ at JSON Schema location ’#’", "schema-location": "#", "document-location": "#", "schema-failed-keyword": "required" } 1 row in set (0.00 sec) 

If we now set the value of @schema  to the same JSON schema but without the required  attribute, @document  validates because it is a valid JSON object, even though it contains no properties, as shown here: 

mysql> SET @schema = ’{ ’> "id": "http://json-schema.org/geo", ’> "$schema": "http://json-schema.org/draft-04/schema#", ’> "description": "A geographical coordinate", ’> "type": "object", ’> "properties": { ’> "latitude": { ’> "type": "number", ’> "minimum": -90, ’> "maximum": 90 ’> }, ’> "longitude": { ’> "type": "number", ’> "minimum": -180, ’> "maximum": 180 ’> } ’> } 

