couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randall Leeds <randall.le...@gmail.com>
Subject Re: Declarative validation of recursive documents
Date Tue, 13 Sep 2011 08:10:43 GMT
2011/9/12 Daniel ItaboraĆ­ <itaborai83@gmail.com>

> It seems to me that it would be useful to be able to declaratively specify
> this tree like schema to validate complex documents, something like the
> following
>
> <snip>

>
> Is this sort of thing useful? And more importantly, is there anything
> that already does this better?
>

CouchDB-python[1] has a mapping module[2].
Mikeal's couchdb-pythonviews[3] is a python view server that supports
validation functions.

Depending on your needs, you might accomplish the job with just these.

For example, if you're okay with accepting documents where all the fields
coerce to their expected types even if they were not exact matches, you
could just use the couchdb.mapping.Document.wrap on input to your validation
function. This would, for example, generate exceptions when a DateField
fails to parse as a date.

If you need something more strict, like rejecting JSON numbers where you
expect strings, you could probably add python type information to the
mapping classes and a validate() function to the base class.

Hope that's enough to get you started. I'm not aware of anything like this
that exists already, but if it does hopefully the list will chime in.

[1] https://code.google.com/p/couchdb-python/
[2]
https://code.google.com/p/couchdb-python/source/browse/couchdb/mapping.py
[3] https://github.com/mikeal/couchdb-pythonviews


> Thanks,
> Daniel
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message