<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="json-validation-functions">
      </a>
      14.17.7 JSON Schema Validation Functions
     </h3>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045194480000">
  </a>
  <p>
   MySQL supports validation of JSON documents against JSON schemas
      conforming to
   <a class="ulink" href="https://json-schema.org/specification-links.html#draft-4" target="_blank">
    Draft
      4 of the JSON Schema specification
   </a>
   . This can be done using
      either of the functions detailed in this section, both of which
      take two arguments, a JSON schema, and a JSON document which is
      validated against the schema.
   <a class="link" href="json-validation-functions.html#function_json-schema-valid">
    <code class="literal">
     JSON_SCHEMA_VALID()
    </code>
   </a>
   returns true if
      the document validates against the schema, and false if it does
      not;
   <a class="link" href="json-validation-functions.html#function_json-schema-validation-report">
    <code class="literal">
     JSON_SCHEMA_VALIDATION_REPORT()
    </code>
   </a>
   provides a report in JSON format on the validation.
  </p>
  <p>
   Both functions handle null or invalid input as follows:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <p>
      If at least one of the arguments is
      <code class="literal">
       NULL
      </code>
      ,
          the function returns
      <code class="literal">
       NULL
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      If at least one of the arguments is not valid JSON, the
          function raises an error
          (
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_invalid_type_for_json" target="_top">
       <code class="literal">
        ER_INVALID_TYPE_FOR_JSON
       </code>
      </a>
      )
     </p>
    </li>
    <li class="listitem">
     <p>
      In addition, if the schema is not a valid JSON object, the
          function returns
      <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_invalid_json_type" target="_top">
       <code class="literal">
        ER_INVALID_JSON_TYPE
       </code>
      </a>
      .
     </p>
    </li>
   </ul>
  </div>
  <p>
   MySQL supports the
   <code class="literal">
    required
   </code>
   attribute in JSON
      schemas to enforce the inclusion of required properties (see the
      examples in the function descriptions).
  </p>
  <p>
   MySQL supports the
   <code class="literal">
    id
   </code>
   ,
   <code class="literal">
    $schema
   </code>
   ,
   <code class="literal">
    description
   </code>
   , and
   <code class="literal">
    type
   </code>
   attributes in JSON schemas but does not
      require any of these.
  </p>
  <p>
   MySQL does not support external resources in JSON schemas; using
      the
   <code class="literal">
    $ref
   </code>
   keyword causes
   <code class="literal">
    JSON_SCHEMA_VALID()
   </code>
   to fail with
   <a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_not_supported_yet" target="_top">
    <code class="literal">
     ER_NOT_SUPPORTED_YET
    </code>
   </a>
   .
  </p>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    MySQL supports regular expression patterns in JSON schema, which
        supports but silently ignores invalid patterns (see the
        description of
    <code class="literal">
     JSON_SCHEMA_VALID()
    </code>
    for an
        example).
   </p>
  </div>
  <p>
   These functions are described in detail in the following list:
  </p>
  <div class="itemizedlist">
   <ul class="itemizedlist" style="list-style-type: disc; ">
    <li class="listitem">
     <a name="function_json-schema-valid">
     </a>
     <p>
      <a class="link" href="json-validation-functions.html#function_json-schema-valid">
       <code class="literal">
        JSON_SCHEMA_VALID(
        <em class="replaceable">
         <code>
          schema
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          document
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045194452080">
     </a>
     <p>
      Validates a JSON
      <em class="replaceable">
       <code>
        document
       </code>
      </em>
      against a
          JSON
      <em class="replaceable">
       <code>
        schema
       </code>
      </em>
      . Both
      <em class="replaceable">
       <code>
        schema
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        document
       </code>
      </em>
      are required. The schema
          must be a valid JSON object; the document must be a valid JSON
          document. Provided that these conditions are met: If the
          document validates against the schema, the function returns
          true (1); otherwise, it returns false (0).
     </p>
     <p>
      In this example, we set a user variable
      <code class="literal">
       @schema
      </code>
      to the value of a JSON schema for
          geographical coordinates, and another one
      <code class="literal">
       @document
      </code>
      to the value of a JSON document
          containing one such coordinate. We then verify that
      <code class="literal">
       @document
      </code>
      validates according to
      <code class="literal">
       @schema
      </code>
      by using them as the arguments to
      <code class="literal">
       JSON_SCHEMA_VALID()
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa57905850"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@schema</span> <span class="token operator">=</span> <span class="token string">'{
    '</span><span class="token operator">&gt;</span>  <span class="token string">"id"</span>: <span class="token string">"http://json-schema.org/geo"</span><span class="token punctuation">,</span>
    '<span class="token operator">&gt;</span> <span class="token string">"$schema"</span>: <span class="token string">"http://json-schema.org/draft-04/schema#"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "description": "A geographical coordinate",
    '</span><span class="token operator">&gt;</span> <span class="token string">"type"</span>: <span class="token string">"object"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "properties": {
    '</span><span class="token operator">&gt;</span>   <span class="token string">"latitude"</span>: {
    <span class="token string">'&gt;     "type": "number",
    '</span><span class="token operator">&gt;</span>     <span class="token string">"minimum"</span>: <span class="token operator">-</span><span class="token number">90</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "maximum": 90
    '</span><span class="token operator">&gt;</span>   }<span class="token punctuation">,</span>
    <span class="token string">'&gt;   "longitude": {
    '</span><span class="token operator">&gt;</span>     <span class="token string">"type"</span>: <span class="token string">"number"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "minimum": -180,
    '</span><span class="token operator">&gt;</span>     <span class="token string">"maximum"</span>: <span class="token number">180</span>
    <span class="token string">'&gt;   }
    '</span><span class="token operator">&gt;</span> }<span class="token punctuation">,</span>
    <span class="token string">'&gt; "required": ["latitude", "longitude"]
    '</span><span class="token operator">&gt;</span>}<span class="token string">';
Query OK, 0 rows affected (0.01 sec)

mysql&gt; SET @document = '</span>{
    <span class="token string">'&gt; "latitude": 63.444697,
    '</span><span class="token operator">&gt;</span> <span class="token string">"longitude"</span>: <span class="token number">10.445118</span>
    <span class="token string">'&gt;}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALID<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALID(@schema, @document) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                                     1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      Since
      <code class="literal">
       @schema
      </code>
      contains the
      <code class="literal">
       required
      </code>
      attribute, we can set
      <code class="literal">
       @document
      </code>
      to a value that is otherwise
          valid but does not contain the required properties, then test
          it against
      <code class="literal">
       @schema
      </code>
      , like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40546127"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@document</span> <span class="token operator">=</span> <span class="token string">'{}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALID<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALID(@schema, @document) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                                     0 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      If we now set the value of
      <code class="literal">
       @schema
      </code>
      to the
          same JSON schema but without the
      <code class="literal">
       required
      </code>
      attribute,
      <code class="literal">
       @document
      </code>
      validates because it
          is a valid JSON object, even though it contains no properties,
          as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7505595"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@schema</span> <span class="token operator">=</span> <span class="token string">'{
    '</span><span class="token operator">&gt;</span> <span class="token string">"id"</span>: <span class="token string">"http://json-schema.org/geo"</span><span class="token punctuation">,</span>
    '<span class="token operator">&gt;</span> <span class="token string">"$schema"</span>: <span class="token string">"http://json-schema.org/draft-04/schema#"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "description": "A geographical coordinate",
    '</span><span class="token operator">&gt;</span> <span class="token string">"type"</span>: <span class="token string">"object"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "properties": {
    '</span><span class="token operator">&gt;</span>   <span class="token string">"latitude"</span>: {
    <span class="token string">'&gt;     "type": "number",
    '</span><span class="token operator">&gt;</span>     <span class="token string">"minimum"</span>: <span class="token operator">-</span><span class="token number">90</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "maximum": 90
    '</span><span class="token operator">&gt;</span>   }<span class="token punctuation">,</span>
    <span class="token string">'&gt;   "longitude": {
    '</span><span class="token operator">&gt;</span>     <span class="token string">"type"</span>: <span class="token string">"number"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "minimum": -180,
    '</span><span class="token operator">&gt;</span>     <span class="token string">"maximum"</span>: <span class="token number">180</span>
    <span class="token string">'&gt;   }
    '</span><span class="token operator">&gt;</span> }
    <span class="token string">'&gt;}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>


<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALID<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALID(@schema, @document) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                                     1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <a class="indexterm" name="idm46045194400752">
     </a>
     <a class="indexterm" name="idm46045194399248">
     </a>
     <p>
      <a name="json-validation-functions-constraints">
      </a>
      <b>
       JSON_SCHEMA_VALID() and CHECK constraints.
      </b>
      <code class="literal">
       JSON_SCHEMA_VALID()
      </code>
      can also be used to
            enforce
      <code class="literal">
       CHECK
      </code>
      constraints.
     </p>
     <p>
      Consider the table
      <code class="literal">
       geo
      </code>
      created as shown
          here, with a JSON column
      <code class="literal">
       coordinate
      </code>
      representing a point of latitude and longitude on a map,
          governed by the JSON schema used as an argument in a
      <code class="literal">
       JSON_SCHEMA_VALID()
      </code>
      call which is passed as
          the expression for a
      <code class="literal">
       CHECK
      </code>
      constraint on
          this table:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69760201"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> geo <span class="token punctuation">(</span>
<span class="token prompt">    -&gt;</span>     coordinate <span class="token datatype">JSON</span><span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>     <span class="token keyword">CHECK</span><span class="token punctuation">(</span>
<span class="token prompt">    -&gt;</span>         JSON_SCHEMA_VALID<span class="token punctuation">(</span>
<span class="token prompt">    -&gt;</span>             <span class="token string">'{
    '</span><span class="token operator">&gt;</span>                 <span class="token string">"type"</span>:<span class="token string">"object"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;                 "properties":{
    '</span><span class="token operator">&gt;</span>                       <span class="token string">"latitude"</span>:{<span class="token string">"type"</span>:<span class="token string">"number"</span><span class="token punctuation">,</span> <span class="token string">"minimum"</span>:<span class="token operator">-</span><span class="token number">90</span><span class="token punctuation">,</span> <span class="token string">"maximum"</span>:<span class="token number">90</span>}<span class="token punctuation">,</span>
    <span class="token string">'&gt;                       "longitude":{"type":"number", "minimum":-180, "maximum":180}
    '</span><span class="token operator">&gt;</span>                 }<span class="token punctuation">,</span>
    <span class="token string">'&gt;                 "required": ["latitude", "longitude"]
    '</span><span class="token operator">&gt;</span>             }'<span class="token punctuation">,</span>
<span class="token prompt">    -&gt;</span>             coordinate
<span class="token prompt">    -&gt;</span>         <span class="token punctuation">)</span>
<span class="token prompt">    -&gt;</span>     <span class="token punctuation">)</span>
<span class="token prompt">    -&gt;</span> <span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.45 sec)</span></code></pre>
     </div>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       Because a MySQL
       <code class="literal">
        CHECK
       </code>
       constraint cannot
            contain references to variables, you must pass the JSON
            schema to
       <code class="literal">
        JSON_SCHEMA_VALID()
       </code>
       inline when
            using it to specify such a constraint for a table.
      </p>
     </div>
     <p>
      We assign JSON values representing coordinates to three
          variables, as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75393002"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@point1</span> <span class="token operator">=</span> <span class="token string">'{"latitude":59, "longitude":18}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@point2</span> <span class="token operator">=</span> <span class="token string">'{"latitude":91, "longitude":0}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@point3</span> <span class="token operator">=</span> <span class="token string">'{"longitude":120}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span></code></pre>
     </div>
     <p>
      The first of these values is valid, as can be seen in the
          following
      <a class="link" href="insert.html" title="15.2.7 INSERT Statement">
       <code class="literal">
        INSERT
       </code>
      </a>
      statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa72800134"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> geo <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token variable">@point1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.05 sec)</span></code></pre>
     </div>
     <p>
      The second JSON value is invalid and so fails the constraint,
          as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46205486"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> geo <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token variable">@point2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3819 (HY000)<span class="token punctuation">:</span> Check constraint 'geo_chk_1' is violated.</span></code></pre>
     </div>
     <p>
      You can obtain precise information about the nature of the
          failure—in this case, that the
      <code class="literal">
       latitude
      </code>
      value exceeds the maximum defined
          in the schema—by issuing a
      <a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
       <code class="literal">
        SHOW
          WARNINGS
       </code>
      </a>
      statement:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa62737864"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Error
   Code<span class="token punctuation">:</span> 3934
Message<span class="token punctuation">:</span> The JSON document location '#/latitude' failed requirement 'maximum' at
JSON Schema location '#/properties/latitude'.
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Error
   Code<span class="token punctuation">:</span> 3819
Message<span class="token punctuation">:</span> Check constraint 'geo_chk_1' is violated.
</span><span class="token output">2 rows in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      The third coordinate value defined above is also invalid,
          since it is missing the required
      <code class="literal">
       latitude
      </code>
      property. As before, you can see this by attempting to insert
          the value into the
      <code class="literal">
       geo
      </code>
      table, then issuing
      <code class="literal">
       SHOW WARNINGS
      </code>
      afterwards:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70545345"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> geo <span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token variable">@point3</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3819 (HY000)<span class="token punctuation">:</span> Check constraint 'geo_chk_1' is violated.</span>
<span class="token prompt">mysql&gt;</span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Error
   Code<span class="token punctuation">:</span> 3934
Message<span class="token punctuation">:</span> The JSON document location '#' failed requirement 'required' at JSON
Schema location '#'.
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
  Level<span class="token punctuation">:</span> Error
   Code<span class="token punctuation">:</span> 3819
Message<span class="token punctuation">:</span> Check constraint 'geo_chk_1' is violated.
</span><span class="token output">2 rows in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      See
      <a class="xref" href="create-table-check-constraints.html" title="15.1.20.6 CHECK Constraints">
       Section 15.1.20.6, “CHECK Constraints”
      </a>
      , for more
          information.
     </p>
     <a class="indexterm" name="idm46045194355824">
     </a>
     <p>
      JSON Schema has support for specifying regular expression
          patterns for strings, but the implementation used by MySQL
          silently ignores invalid patterns. This means that
      <code class="literal">
       JSON_SCHEMA_VALID()
      </code>
      can return true even
          when a regular expression pattern is invalid, as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63481435"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALID<span class="token punctuation">(</span><span class="token string">'{"type":"string","pattern":"("}'</span><span class="token punctuation">,</span> <span class="token string">'"abc"'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALID('{"type":"string","pattern":"("}', '"abc"') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span>                                                             1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.04 sec)</span></code></pre>
     </div>
    </li>
    <li class="listitem">
     <a name="function_json-schema-validation-report">
     </a>
     <p>
      <a class="link" href="json-validation-functions.html#function_json-schema-validation-report">
       <code class="literal">
        JSON_SCHEMA_VALIDATION_REPORT(
        <em class="replaceable">
         <code>
          schema
         </code>
        </em>
        ,
        <em class="replaceable">
         <code>
          document
         </code>
        </em>
        )
       </code>
      </a>
     </p>
     <a class="indexterm" name="idm46045194345040">
     </a>
     <p>
      Validates a JSON
      <em class="replaceable">
       <code>
        document
       </code>
      </em>
      against a
          JSON
      <em class="replaceable">
       <code>
        schema
       </code>
      </em>
      . Both
      <em class="replaceable">
       <code>
        schema
       </code>
      </em>
      and
      <em class="replaceable">
       <code>
        document
       </code>
      </em>
      are required. As with
          JSON_VALID_SCHEMA(), the schema must be a valid JSON object,
          and the document must be a valid JSON document. Provided that
          these conditions are met, the function returns a report, as a
          JSON document, on the outcome of the validation. If the JSON
          document is considered valid according to the JSON Schema, the
          function returns a JSON object with one property
      <code class="literal">
       valid
      </code>
      having the value "true". If the JSON
          document fails validation, the function returns a JSON object
          which includes the properties listed here:
     </p>
     <div class="itemizedlist">
      <ul class="itemizedlist" style="list-style-type: circle; ">
       <li class="listitem">
        <p>
         <code class="literal">
          valid
         </code>
         : Always "false" for a failed
              schema validation
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          reason
         </code>
         : A human-readable string
              containing the reason for the failure
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          schema-location
         </code>
         : A JSON pointer URI
              fragment identifier indicating where in the JSON schema
              the validation failed (see Note following this list)
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          document-location
         </code>
         : A JSON pointer URI
              fragment identifier indicating where in the JSON document
              the validation failed (see Note following this list)
        </p>
       </li>
       <li class="listitem">
        <p>
         <code class="literal">
          schema-failed-keyword
         </code>
         : A string
              containing the name of the keyword or property in the JSON
              schema that was violated
        </p>
       </li>
      </ul>
     </div>
     <a class="indexterm" name="idm46045194332000">
     </a>
     <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
      <div class="admon-title">
       Note
      </div>
      <p>
       JSON pointer URI fragment identifiers are defined in
       <a class="ulink" href="https://tools.ietf.org/html/rfc6901#page-5" target="_blank">
        RFC
            6901 - JavaScript Object Notation (JSON) Pointer
       </a>
       .
            (These are
       <span class="emphasis">
        <em>
         not
        </em>
       </span>
       the same as the JSON
            path notation used by
       <a class="link" href="json-search-functions.html#function_json-extract">
        <code class="literal">
         JSON_EXTRACT()
        </code>
       </a>
       and other
            MySQL JSON functions.) In this notation,
       <code class="literal">
        #
       </code>
       represents the entire document, and
       <code class="literal">
        #/myprop
       </code>
       represents the portion of the
            document included in the top-level property named
       <code class="literal">
        myprop
       </code>
       . See the specification just cited
            and the examples shown later in this section for more
            information.
      </p>
     </div>
     <p>
      In this example, we set a user variable
      <code class="literal">
       @schema
      </code>
      to the value of a JSON schema for
          geographical coordinates, and another one
      <code class="literal">
       @document
      </code>
      to the value of a JSON document
          containing one such coordinate. We then verify that
      <code class="literal">
       @document
      </code>
      validates according to
      <code class="literal">
       @schema
      </code>
      by using them as the arguments to
      <code class="literal">
       JSON_SCHEMA_VALIDATION_REORT()
      </code>
      :
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa84162602"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@schema</span> <span class="token operator">=</span> <span class="token string">'{
    '</span><span class="token operator">&gt;</span>  <span class="token string">"id"</span>: <span class="token string">"http://json-schema.org/geo"</span><span class="token punctuation">,</span>
    '<span class="token operator">&gt;</span> <span class="token string">"$schema"</span>: <span class="token string">"http://json-schema.org/draft-04/schema#"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "description": "A geographical coordinate",
    '</span><span class="token operator">&gt;</span> <span class="token string">"type"</span>: <span class="token string">"object"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "properties": {
    '</span><span class="token operator">&gt;</span>   <span class="token string">"latitude"</span>: {
    <span class="token string">'&gt;     "type": "number",
    '</span><span class="token operator">&gt;</span>     <span class="token string">"minimum"</span>: <span class="token operator">-</span><span class="token number">90</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "maximum": 90
    '</span><span class="token operator">&gt;</span>   }<span class="token punctuation">,</span>
    <span class="token string">'&gt;   "longitude": {
    '</span><span class="token operator">&gt;</span>     <span class="token string">"type"</span>: <span class="token string">"number"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "minimum": -180,
    '</span><span class="token operator">&gt;</span>     <span class="token string">"maximum"</span>: <span class="token number">180</span>
    <span class="token string">'&gt;   }
    '</span><span class="token operator">&gt;</span> }<span class="token punctuation">,</span>
    <span class="token string">'&gt; "required": ["latitude", "longitude"]
    '</span><span class="token operator">&gt;</span>}<span class="token string">';
Query OK, 0 rows affected (0.01 sec)

mysql&gt; SET @document = '</span>{
    <span class="token string">'&gt; "latitude": 63.444697,
    '</span><span class="token operator">&gt;</span> <span class="token string">"longitude"</span>: <span class="token number">10.445118</span>
    <span class="token string">'&gt;}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALIDATION_REPORT<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALIDATION_REPORT(@schema, @document) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> {"valid": true}                                   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      Now we set
      <code class="literal">
       @document
      </code>
      such that it specifies
          an illegal value for one of its properties, like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65700876"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@document</span> <span class="token operator">=</span> <span class="token string">'{
    '</span><span class="token operator">&gt;</span> <span class="token string">"latitude"</span>: <span class="token number">63.444697</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "longitude": 310.445118
    '</span><span class="token operator">&gt;</span> }'<span class="token punctuation">;</span></code></pre>
     </div>
     <p>
      Validation of
      <code class="literal">
       @document
      </code>
      now fails when
          tested with
      <code class="literal">
       JSON_SCHEMA_VALIDATION_REPORT()
      </code>
      . The output
          from the function call contains detailed information about the
          failure (with the function wrapped by
      <a class="link" href="json-utility-functions.html#function_json-pretty">
       <code class="literal">
        JSON_PRETTY()
       </code>
      </a>
      to provide better
          formatting), as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28651431"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">JSON_PRETTY</span><span class="token punctuation">(</span>JSON_SCHEMA_VALIDATION_REPORT<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document))<span class="token punctuation">:</span> {
  "valid"<span class="token punctuation">:</span> false,
  "reason"<span class="token punctuation">:</span> "The JSON document location '#/longitude' failed requirement 'maximum' at JSON Schema location '#/properties/longitude'",
  "schema-location"<span class="token punctuation">:</span> "#/properties/longitude",
  "document-location"<span class="token punctuation">:</span> "#/longitude",
  "schema-failed-keyword"<span class="token punctuation">:</span> "maximum"
}
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      Since
      <code class="literal">
       @schema
      </code>
      contains the
      <code class="literal">
       required
      </code>
      attribute, we can set
      <code class="literal">
       @document
      </code>
      to a value that is otherwise
          valid but does not contain the required properties, then test
          it against
      <code class="literal">
       @schema
      </code>
      . The output of
      <code class="literal">
       JSON_SCHEMA_VALIDATION_REPORT()
      </code>
      shows that
          validation fails due to lack of a required element, like this:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa29854974"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@document</span> <span class="token operator">=</span> <span class="token string">'{}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> <span class="token function">JSON_PRETTY</span><span class="token punctuation">(</span>JSON_SCHEMA_VALIDATION_REPORT<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">)</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
JSON_PRETTY(JSON_SCHEMA_VALIDATION_REPORT(@schema, @document))<span class="token punctuation">:</span> {
  "valid"<span class="token punctuation">:</span> false,
  "reason"<span class="token punctuation">:</span> "The JSON document location '#' failed requirement 'required' at JSON Schema location '#'",
  "schema-location"<span class="token punctuation">:</span> "#",
  "document-location"<span class="token punctuation">:</span> "#",
  "schema-failed-keyword"<span class="token punctuation">:</span> "required"
}
</span><span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
     <p>
      If we now set the value of
      <code class="literal">
       @schema
      </code>
      to the
          same JSON schema but without the
      <code class="literal">
       required
      </code>
      attribute,
      <code class="literal">
       @document
      </code>
      validates because it
          is a valid JSON object, even though it contains no properties,
          as shown here:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86356495"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql&gt;</span> <span class="token keyword">SET</span> <span class="token variable">@schema</span> <span class="token operator">=</span> <span class="token string">'{
    '</span><span class="token operator">&gt;</span> <span class="token string">"id"</span>: <span class="token string">"http://json-schema.org/geo"</span><span class="token punctuation">,</span>
    '<span class="token operator">&gt;</span> <span class="token string">"$schema"</span>: <span class="token string">"http://json-schema.org/draft-04/schema#"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "description": "A geographical coordinate",
    '</span><span class="token operator">&gt;</span> <span class="token string">"type"</span>: <span class="token string">"object"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt; "properties": {
    '</span><span class="token operator">&gt;</span>   <span class="token string">"latitude"</span>: {
    <span class="token string">'&gt;     "type": "number",
    '</span><span class="token operator">&gt;</span>     <span class="token string">"minimum"</span>: <span class="token operator">-</span><span class="token number">90</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "maximum": 90
    '</span><span class="token operator">&gt;</span>   }<span class="token punctuation">,</span>
    <span class="token string">'&gt;   "longitude": {
    '</span><span class="token operator">&gt;</span>     <span class="token string">"type"</span>: <span class="token string">"number"</span><span class="token punctuation">,</span>
    <span class="token string">'&gt;     "minimum": -180,
    '</span><span class="token operator">&gt;</span>     <span class="token string">"maximum"</span>: <span class="token number">180</span>
    <span class="token string">'&gt;   }
    '</span><span class="token operator">&gt;</span> }
    <span class="token string">'&gt;}'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.00 sec)</span>

<span class="token prompt">mysql&gt;</span> <span class="token keyword">SELECT</span> JSON_SCHEMA_VALIDATION_REPORT<span class="token punctuation">(</span><span class="token variable">@schema</span><span class="token punctuation">,</span> <span class="token variable">@document</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> JSON_SCHEMA_VALIDATION_REPORT(@schema, @document) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> {"valid": true}                                   <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
     </div>
    </li>
   </ul>
  </div>
 </div>
 <br/>
</div>
