Validictory JSON schema validator Alex Conrad Code Monkey, SurveyMonkey @alexconrad Pylons miniconf – April 29, 2011 Pylon...
What is validictory? A simple Python library to validate JSON data.
What do you use it for? Validate web service APIs that talk JSON.
How does it work? One function. Two arguments. <ul>>>> import validictory >>> validictory.validate(data, schema) </ul>
How does it work? What is ``data`` ? A Python datatype loaded from JSON data. <ul>>>> import json >>> data = json.loads(re...
How does it work? What is ``schema`` ? A Python dictionary describing how the data should be formed. <ul>>>> schema = {”ty...
How does it work? Invalid data. <ul>>>> validictory.validate(”USA”, schema) Traceback (most recent call last): ValidationE...
How does it work? Re-usable schemas, just plain Python. <ul>>>>  country  = {”type”: ”string”, ...  ”minLength”: 2, ...  ”...
References pypi.python.org/pypi/validictory json-schema.org
Questions? Thank you. @alexconrad
Upcoming SlideShare
Loading in …5
×

Validictory

1,508 views
1,379 views

Published on

"Validictory" lightning talk given at the Pylons Mini Conf at Yelp in San Francisco, by Alexandre Conrad, on April 29 2011.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,508
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Validictory

  1. 1. Validictory JSON schema validator Alex Conrad Code Monkey, SurveyMonkey @alexconrad Pylons miniconf – April 29, 2011 Pylons miniconf
  2. 2. What is validictory? A simple Python library to validate JSON data.
  3. 3. What do you use it for? Validate web service APIs that talk JSON.
  4. 4. How does it work? One function. Two arguments. <ul>>>> import validictory >>> validictory.validate(data, schema) </ul>
  5. 5. How does it work? What is ``data`` ? A Python datatype loaded from JSON data. <ul>>>> import json >>> data = json.loads(request.body) </ul>
  6. 6. How does it work? What is ``schema`` ? A Python dictionary describing how the data should be formed. <ul>>>> schema = {”type”: ”string”, ... ”minLength”: 2, ... ”maxLength”: 2} </ul>
  7. 7. How does it work? Invalid data. <ul>>>> validictory.validate(”USA”, schema) Traceback (most recent call last): ValidationError: Length of value 'USA' for field '_data' must be less than or equal to 2 </ul>
  8. 8. How does it work? Re-usable schemas, just plain Python. <ul>>>> country = {”type”: ”string”, ... ”minLength”: 2, ... ”maxLength”: 2} >>> address = {”type”: ”object”, ... ”properties”: { ... ”street”: {”type”:”string”}, ... ”country”: country }} </ul>
  9. 9. References pypi.python.org/pypi/validictory json-schema.org
  10. 10. Questions? Thank you. @alexconrad

×