Using jsonschema as a "validation backend" in another library

91 views
Skip to first unread message

Paul Walsh

unread,
Jan 20, 2015, 2:54:38 AM1/20/15
to jsons...@googlegroups.com
Hi,

I'm looking to use JSON Schema as a validation backend in a library I'm working on. 

The library takes a data source (CSV, JSON) and runs it through a pipeline to *validate* and *transform* the data. 

I have standard error interface for the pipeline (so I wouldn't be using the jsonschema errors directly in what is returned to the calling code).

Specifically, I want to be able to call validate per row/object/item of data, as I'm iterating over a stream of data, and doing transforms as it moves from one processor to the next (the JSON schema processor being one of the processors).

So I'd like something like:

for row in data:
    valid, row, errors = validate_row_against_schema(row)

Instead of the normal jsonschema.validate function.

I'm just getting to know the code here, but perhaps someone here can point me in the right direction.


nick...@gmail.com

unread,
Feb 3, 2015, 6:51:55 AM2/3/15
to jsons...@googlegroups.com
If I may chime in with a small idea, you could try work asynchronously and make the pipeline into an iterator that yields the validator each row/object/item of data.
As iter_errors also seems to be an iterator or at least, you could feed from that the other way and raise errors immidiately.
I would appear to me that some kind of solution like this would require comparatively small modifications.

//Nicklas
Reply all
Reply to author
Forward
0 new messages