# Validate JSON document against schema

**URL:** <https://discuss.prosemirror.net/t/validate-json-document-against-schema/786>\
**Category:** Uncategorized\
**Created:** [May 19, 2017, 4:29pm UTC](https://discuss.prosemirror.net/t/validate-json-document-against-schema/786 "2017-05-19T16:29:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elgow](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/elgow/32/421_2.png) [@elgow](https://discuss.prosemirror.net/u/elgow)\
**Post date:** [May 19, 2017, 4:29pm UTC](https://discuss.prosemirror.net/t/validate-json-document-against-schema/786/1 "2017-05-19T16:29:08Z")

</div>

When loading a JSON representation of a document into the ProseMirror editor my experience has been that the rendering will fail silently if the JSON document does not conform to the schema. This results in a lot of wasted time manually validating documents against schema. Is there now, or could there be, some function that will validate a JSON doc against a schema spec? Ideally any point where validation failed would be reported to the caller. This would make it dramatically easier to build applications that store ProseMirror documents in JSON.

Ed

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/marijn/32/15_2.png) [@marijn](https://discuss.prosemirror.net/u/marijn)\
**Post date:** [May 19, 2017, 4:41pm UTC](https://discuss.prosemirror.net/t/validate-json-document-against-schema/786/2 "2017-05-19T16:41:17Z")

</div>

> [@elgow](#):
>
> Is there now, or could there be, some function that will validate a JSON doc against a schema spec?

[Yes](http://prosemirror.net/docs/ref/#model.Node.check), there is.

---

<div class="post-metadata">

**Author:** ![elgow](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/elgow/32/421_2.png) [@elgow](https://discuss.prosemirror.net/u/elgow)\
**Post date:** [May 19, 2017, 5:30pm UTC](https://discuss.prosemirror.net/t/validate-json-document-against-schema/786/3 "2017-05-19T17:30:05Z")

</div>

Thanks Marijn,

Sorry, I was looking under Schema for the function rather than Node. I’ll start calling check() on my doc before loading.

Ed

---

<div class="post-metadata">

**Author:** ![disarticulate](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/disarticulate/32/1303_2.png) [@disarticulate](https://discuss.prosemirror.net/u/disarticulate)\
**Post date:** [January 19, 2020, 5:58pm UTC](https://discuss.prosemirror.net/t/validate-json-document-against-schema/786/4 "2020-01-19T17:58:23Z")

</div>

This appears outdated?

```auto
// "prosemirror-model": "1.8.2"
// 
try {
        let doc = this.editor.createDocument(content)
        doc.check()
        console.log(this.editor, content, doc)
        /*vm.identityService.send(
          SET_DOC, { doc: doc.toJSON() }
        )*/
   } catch (e) {
        console.log(e)
   }

```

All I get is the console warning. Check returns undefined either way.

How do i validate with an schema or editor context?
