’> "description": "A geographical coordinate", ’> "type": "object", ’> "properties": { ’> "latitude": { ’> "type": "number", ’> "minimum": -90, ’> "maximum": 90 ’> }, ’> "longitude": { ’> "type": "number", ’> "minimum": -180, ’> "maximum": 180 ’> } ’> }, ’> "required": ["latitude", "longitude"] ’> }’; Query OK, 0 rows affected (0.01 sec) mysql> SET @document = ’{ ’> "latitude": 63.444697, ’> "longitude": 10.445118 ’> }’; Query OK, 0 rows affected (0.00 sec) mysql> SELECT JSON_SCHEMA_VALID(@schema, @document); +---------------------------------------+ | JSON_SCHEMA_VALID(@schema, @document) | +---------------------------------------+ | 1 | +---------------------------------------+ 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 , like this: 

mysql> SET @document = ’{}’; Query OK, 0 rows affected (0.00 sec) mysql> SELECT JSON_SCHEMA_VALID(@schema, @document); +---------------------------------------+ | JSON_SCHEMA_VALID(@schema, @document) | +---------------------------------------+ | 0 | +---------------------------------------+ 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 ’> } 

