You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Nebu Pookins <ne...@gmail.com> on 2011/04/12 22:09:21 UTC

How does one validate CouchDB documents with JSON Schema?

If I have some JSON Schemas
(http://tools.ietf.org/html/draft-zyp-json-schema-03), is there a way
to pass them onto CouchDB to have CouchDB automatically ensure
documents of a given type (i.e. with their "type" property set to a
specific string) adhere to a specific schema file? I tried some google
searches, but the closest thing I could find to information on the
topic was this blog post
(http://dev.wavemaker.com/forums/?q=node/2618) which implies (but does
not explicitly state) that CouchDB does not support JSON Schemas at
all.

- Nebu

Re: How does one validate CouchDB documents with JSON Schema?

Posted by Ladislav Thon <la...@gmail.com>.
I guess there are some JSON schema validators written in JavaScript out
there. It might be possible (depends on how general the thing should be) to
use them in Couch's validation functions (
http://wiki.apache.org/couchdb/Document_Update_Validation), effectively
resulting in what you describe :-)

LT

2011/4/12 Nebu Pookins <ne...@gmail.com>

> If I have some JSON Schemas
> (http://tools.ietf.org/html/draft-zyp-json-schema-03), is there a way
> to pass them onto CouchDB to have CouchDB automatically ensure
> documents of a given type (i.e. with their "type" property set to a
> specific string) adhere to a specific schema file? I tried some google
> searches, but the closest thing I could find to information on the
> topic was this blog post
> (http://dev.wavemaker.com/forums/?q=node/2618) which implies (but does
> not explicitly state) that CouchDB does not support JSON Schemas at
> all.
>
> - Nebu
>

Re: How does one validate CouchDB documents with JSON Schema?

Posted by Ryan Ramage <ry...@gmail.com>.
Nothing explicit in couch to support json schemas (I think).

But you could create a validation function.
http://guide.couchdb.org/draft/validation.html

You would need to find a suitable javascript library that performed
schema validation and insert it into the design doc, and than call it
from the validation function based on the type on the document.

Ryan

On Tue, Apr 12, 2011 at 2:09 PM, Nebu Pookins <ne...@gmail.com> wrote:
> If I have some JSON Schemas
> (http://tools.ietf.org/html/draft-zyp-json-schema-03), is there a way
> to pass them onto CouchDB to have CouchDB automatically ensure
> documents of a given type (i.e. with their "type" property set to a
> specific string) adhere to a specific schema file? I tried some google
> searches, but the closest thing I could find to information on the
> topic was this blog post
> (http://dev.wavemaker.com/forums/?q=node/2618) which implies (but does
> not explicitly state) that CouchDB does not support JSON Schemas at
> all.
>
> - Nebu
>