Validictory
Upcoming SlideShare
Loading in...5
×
 

Validictory

on

  • 1,517 views

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

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

Statistics

Views

Total Views
1,517
Views on SlideShare
1,517
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Validictory Validictory Presentation Transcript

  • Validictory JSON schema validator Alex Conrad Code Monkey, SurveyMonkey @alexconrad Pylons miniconf – April 29, 2011 Pylons miniconf
  • 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.
      >>> import validictory >>> validictory.validate(data, schema)
  • How does it work? What is ``data`` ? A Python datatype loaded from JSON data.
      >>> import json >>> data = json.loads(request.body)
  • How does it work? What is ``schema`` ? A Python dictionary describing how the data should be formed.
      >>> schema = {”type”: ”string”, ... ”minLength”: 2, ... ”maxLength”: 2}
  • How does it work? Invalid data.
      >>> 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
  • How does it work? Re-usable schemas, just plain Python.
      >>> country = {”type”: ”string”, ... ”minLength”: 2, ... ”maxLength”: 2} >>> address = {”type”: ”object”, ... ”properties”: { ... ”street”: {”type”:”string”}, ... ”country”: country }}
  • References pypi.python.org/pypi/validictory json-schema.org
  • Questions? Thank you. @alexconrad