Skip to content

Commit

Permalink
Merge 320918f into bcdec9d
Browse files Browse the repository at this point in the history
  • Loading branch information
gabisurita committed May 13, 2017
2 parents bcdec9d + 320918f commit 40f8cdc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ Some common use cases:
Example
=======

This is a simple Model. ::
This is a simple Model.

.. code:: python
>>> from schematics.models import Model
>>> from schematics.types import StringType, URLType
Expand All @@ -66,13 +68,17 @@ This is a simple Model. ::
>>> person.name
u'Joe Strummer'
Serializing the data to JSON. ::
Serializing the data to JSON.

.. code:: python
>>> import json
>>> json.dumps(person.to_primitive())
{"name": "Joe Strummer", "website": "http://soundcloud.com/joestrummer"}
Let's try validating without a name value, since it's required. ::
Let's try validating without a name value, since it's required.

.. code:: python
>>> person = Person()
>>> person.website = 'http://www.amontobin.com/'
Expand All @@ -83,7 +89,9 @@ Let's try validating without a name value, since it's required. ::
raise DataError(e.messages)
schematics.exceptions.DataError: {'name': ['This field is required.']}
Add the field and validation passes::
Add the field and validation passes.

.. code:: python
>>> person = Person()
>>> person.name = 'Amon Tobin'
Expand Down

0 comments on commit 40f8cdc

Please sign in to comment.