title: JSON Schema Validation in Mule: get failing field
body: <p>I am using APIkit in Mule with <strong>RAML 0.8</strong> and a JSON schema, as follows (example):</p>
  <pre><code>{
      &quot;$schema&quot;: &quot;http://json-schema.org/draft-04/schema#&quot;,
      
      &quot;type&quot;: &quot;object&quot;,
      
      &quot;properties&quot;: {
          &quot;cart&quot;: {
              &quot;title&quot;: &quot;&quot;,
              &quot;description&quot;: &quot;&quot;,
              &quot;type&quot;: &quot;object&quot;,
              &quot;properties&quot;: {
                  &quot;internalNumber&quot;: {
                      &quot;type&quot;: &quot;integer&quot;
                  }
              },
              &quot;required&quot;: [
                  &quot;internalNumber&quot;
              ]
          }
      },
      &quot;required&quot;: [
          &quot;cart&quot;
      ]
  }
  </code></pre>
  <p>and in the Mule Flow, I catch the exception and show the following result:</p>
  <pre><code>#[exception.cause.message]
  </code></pre>
  <p>When a validation error occurs, I want to get the name of the field in which the validation failed. Instead, this is what I got:</p>
  <h2>Input</h2>
  <pre><code>{
      &quot;cart&quot;: {
          &quot;internalNumber&quot;: &quot;I must be an integer&quot;
      }
  }
  </code></pre>
  <h2>Output</h2>
  <pre><code>&quot;instance type (string) does not match any allowed primitive type (allowed: [&quot;integer&quot;])&quot;
  </code></pre>
  <h2>Expected output</h2>
  <pre><code>{
      &quot;field&quot;: &quot;cart.internalNumber&quot;,
      &quot;error&quot;: &quot;instance type (string) does not match any allowed primitive type (allowed: [&quot;integer&quot;])&quot;
  }
  </code></pre>
  <p>All I want to know is if there is a way to get the name of the field in which the validation errors occurs.</p>
  <p>Regarding the <a href="https://www.mulesoft.org/docs/site/3.7.0/apidocs/org/mule/module/json/validation/JsonSchemaValidationException.html#getInvalidJson()" rel="nofollow noreferrer">Mule Documentation</a>, I can get the whole JSON string but not the name of the failing field...</p>
  <p>I hope someone can give me a better solution.</p>
  <p>Thanks!</p>