title: How to customize error messages for JSONSchema?
body: <p>Is there a way to provide a custom error message depending on the given condition?
  I'm using <a href="https://github.com/networknt/json-schema-validator" rel="nofollow noreferrer">https://github.com/networknt/json-schema-validator</a>, version 1.0.43</p>
  <p>This is my JSON Schema:</p>
  <pre><code>{
    &quot;$id&quot;: &quot;https://configurations/provider.json&quot;,
    &quot;$schema&quot;: &quot;http://json-schema.org/draft-07/schema#&quot;,
    &quot;title&quot;: &quot;Configuration&quot;,
    &quot;type&quot;: &quot;object&quot;,
    &quot;properties&quot;: {
      &quot;provider&quot;: {
        &quot;description&quot;: &quot;Name of the provider.&quot;,
        &quot;enum&quot;: [
          &quot;Provider #1&quot;,
          &quot;Provider #2&quot;
        ]
      },
      &quot;configuration&quot;: {
        &quot;$schema&quot;: &quot;json-schema/configurations/configuration.json&quot;
      }
    },
    &quot;if&quot;: {
      &quot;properties&quot;: {
        &quot;parcsProvider&quot;: {
          &quot;const&quot;: &quot;Provider #1&quot;
        }
      }
    },
    &quot;then&quot;: {
      &quot;required&quot;: [
        &quot;configuration&quot;
      ]
    },
    &quot;else&quot;: {
      &quot;not&quot;: {
        &quot;required&quot;: [
          &quot;configuration&quot;
        ]
      }
    }
  }
  </code></pre>
  <p>If the value for the provider is &quot;Provider #1&quot; then the configuration object is required, and if it's &quot;Provider #2&quot; and configuration is passed an error will occur. I want to customize that error so that the response is the same as it is now but with a custom message like &quot;Provider 2 can't have a configuration.&quot;</p>
  <p>Current error message/response:</p>
  <pre><code>{
      &quot;timestamp&quot;: &quot;2020-11-23T12:50:56.20658+01:00&quot;,
      &quot;message&quot;: &quot;invalid.json.input&quot;,
      &quot;validationErrors&quot;: [
          {
              &quot;field&quot;: &quot;$&quot;,
              &quot;message&quot;: &quot;$: should not be valid to the schema \&quot;not\&quot; : {\&quot;required\&quot;:[\&quot;configuration\&quot;]}&quot;
          }
      ]
  }
  </code></pre>