# JSON Node - Schema validation - ID problem

**URL:** <https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364>\
**Category:** General\
**Created:** [19 June 2021 11:29 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364 "2021-06-19T11:29:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [19 June 2021 11:29 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/1 "2021-06-19T11:29:11Z")

</div>

Hey,

finally i found the root cause of this topic's problem. But the thread is closed ☹

# [JSON Node - Schema validation](https://discourse.nodered.org/t/help-with-json-node-schema-validation/44598)

The reason why i couldn't validate a schema with $id more than once is the missing option in the AJV library.  
[https://ajv.js.org/options.html#addusedschema](https://ajv.js.org/options.html#addusedschema)

With this option it's possible to validate a json schema more than once against other schemata. 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [19 June 2021 15:37 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/2 "2021-06-19T15:37:44Z")

</div>

Hi - in the v2-beta Nick has merged an update for AJV - [Merge pull request #2969 from node-red/ajv-update · node-red/node-red@3d405f8 · GitHub](https://github.com/node-red/node-red/commit/3d405f8c63efb645d4644a1cf3fc96d61320e2f1) - does this help the problem or is something else missing ?

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [20 June 2021 11:35 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/3 "2021-06-20T11:35:56Z")

</div>

Hey dceejay,

I think it should be

```auto
const ajv = new Ajv({allErrors: true, addUsedSchema: false});

```

This allows it to validate json which can also be a schema which contains $id more than once.  
I could try to create a merge request and an example flow demonstrating this monday evening 🙂

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [25 June 2021 21:36 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/4 "2021-06-25T21:36:21Z")

</div>

Sorry i did not found enough time yet to do it.  
This would be my first open source contribution in form of code. Do you maybe have a guideline for this @dceejay?  
**EDIT -\>** i found it [node-red/CONTRIBUTING.md at master · node-red/node-red · GitHub](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)

here is a problematic flow. An example schema copied from [json-schema.org](https://json-schema.org/learn/miscellaneous-examples.html)

```auto
[{"id":"86ca646.c79ea98","type":"json","z":"38d6b820.063658","name":"","property":"payload","action":"obj","pretty":false,"x":490,"y":180,"wires":[["1d7c6628.6d1f6a"]]},{"id":"dc23685b.c41e38","type":"inject","z":"38d6b820.063658","name":"","props":[{"p":"payload"},{"p":"schema","v":"{\"$id\":\"https://example.com/geographical-location.schema.json\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"title\":\"Longitude and Latitude Values\",\"description\":\"A geographical coordinate.\",\"required\":[\"latitude\",\"longitude\"],\"type\":\"object\",\"properties\":{\"latitude\":{\"type\":\"number\",\"minimum\":-90,\"maximum\":90},\"longitude\":{\"type\":\"number\",\"minimum\":-180,\"maximum\":180}}}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"latitude\": 90, \"longitude\":180}","payloadType":"json","x":340,"y":180,"wires":[["86ca646.c79ea98"]]},{"id":"1d7c6628.6d1f6a","type":"debug","z":"38d6b820.063658","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":180,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![H3llsing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/h3llsing/32/40624_2.png) [@H3llsing](https://discourse.nodered.org/u/H3llsing)\
**Post date:** [26 June 2021 17:56 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/5 "2021-06-26T17:56:08Z")

</div>

When i try to checkout the branch `ajv-update`  
and executing

```auto
npm install
npm run build
npm start

```

The browser is not responding on localhost:1880  
The `master` branch is working for me. Did i miss something ?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 August 2021 17:56 UTC](https://discourse.nodered.org/t/json-node-schema-validation-id-problem/47364/6 "2021-08-25T17:56:59Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
