Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schema validation to submit form #28

Open
nepahwin opened this issue Jul 16, 2013 · 4 comments
Open

Add schema validation to submit form #28

nepahwin opened this issue Jul 16, 2013 · 4 comments

Comments

@nepahwin
Copy link
Collaborator

Original note from Adam:

import jsonschema  #https://github.com/Julian/jsonschema
import json

schema = json.loads(open('_attachments/schema/aarm.measurement.v2.01.schema.json').read())
data = json.loads(open('doc/example_assays/example_v2.01_date.json').read())

#this will raise an Exception if data doesn't match the schema
#otherwise is returns None
jsonschema.validate(data, schema)

print 'valid'
@gadamc
Copy link
Collaborator

gadamc commented Jul 17, 2013

Hi... the above example, obviously, is for python. For the client-side JS in the couchapp, we should look into using something from here: http://json-schema.org/implementations.html

note that the schema description is using the version 3 specification - the version 4 specification is very new and I don't know how much has changed.

@nepahwin
Copy link
Collaborator Author

I've come to think that we should only implement the schema in python upload scripts (where it will be important). The application interface is so tightly bound to the data specification that adding the schema will have very little (or no) affect on function. Submit form validation is already handled by existing infrastructure.

@gadamc
Copy link
Collaborator

gadamc commented Jul 22, 2013

Hi James..

The main reason I would implement a validation in the javascript is to make
the software more robust for the developers. I understand that the
application interface well matches the schema, but I would want to make
sure there's some way that protects the app interface developers from
making a mistake in the javascript. I don't think using one of the external
JS libs for validation is very difficult. And I don't think that you will
be in charge of this thing forever and/or looking over everybody's
shoulder. Its like a built-in unit-test to the software that prevents
builders of the website from making mistakes.

$0.02,
Adam

On Mon, Jul 22, 2013 at 12:08 AM, James Loach notifications@github.comwrote:

I've come to think that we should only implement the schema in python
upload scripts (where it will be important). The application interface is
so tightly bound to the data specification that adding the schema will have
very little (or no) affect on function. Submit form validation is already
handled by existing infrastructure.


Reply to this email directly or view it on GitHubhttps://github.com//issues/28#issuecomment-21327806
.

@nepahwin
Copy link
Collaborator Author

Yep, we'll look to implement it. I think your comment re. the developers is a good one.

@nepahwin nepahwin reopened this Jul 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants