title: AJV validate schema with JSONPath strings
body: <p>I'm trying to create a JSON schema that can support validating JSON objects with property values that can either be regular JSON types OR strings representing valid JSONpath expressions.</p>
  
  <p>So for example, given this schema:</p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-07/schema",
    "properties": {
      "age": {
        "type": "number"
      }
    }
  }
  </code></pre>
  
  <p>Either of these JSON objects could be valid:</p>
  
  <pre><code>{
    "age": 30 
  }
  
  {
    "age" "$.age"
  }
  </code></pre>
  
  <p>I've gotten stuck trying to add a custom keyword called <code>jsonPath</code> like this:</p>
  
  <pre><code>{
    "$schema": "http://json-schema.org/draft-07/schema",
    "properties": {
      "age": {
        "type": "number",
        "jsonPath": true
      }
    }
  }
  
  ajv.addKeyword('jsonPath', {
    valid: true,
    compile: () =&gt; data =&gt; {
      return /^\$./.test(data)
    }
  })
  </code></pre>
  
  <p>Ideally I would love to just be able to check if a given property value is a valid JSONPath string and if so, approve it. Otherwise let ajv run it's own validation.</p>
  
  <p>Thanks for any help!</p>