summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Waldon <bcwaldon@gmail.com>2012-06-02 12:25:17 -0700
committerBrian Waldon <bcwaldon@gmail.com>2012-06-02 12:25:17 -0700
commit78cca7b414c45ceaacf621140c5483469e26d03d (patch)
treeb8808e3539c262a6817989aa472d4c91193220cb
parentf123669b5acfb5c2d134fc6a15e1eee866234ddf (diff)
downloadwarlock-78cca7b414c45ceaacf621140c5483469e26d03d.tar.gz
Update README.md
-rw-r--r--README.md38
1 files changed, 27 insertions, 11 deletions
diff --git a/README.md b/README.md
index 9ae3dc4..6228c4d 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,43 @@
# Warlock!
-1) Create a class
+## Wat
- import warlock
+Build self-validating python objects using JSON schemas
- schema = {
+## How
+
+1) Build your schema
+
+ >>> schema = {
'name': 'Country',
'properties': {
'name': {'type': 'string'},
'abbreviation': {'type': 'string'},
},
+ 'additionalProperties': False,
}
- Country = warlock.model_factory(schema)
+2) Create a model
+
+ >>> import warlock
+ >>> Country = warlock.model_factory(schema)
-2) Create an object using your class
+3) Create an object using your model
- sweden = Country(name='Sweden', abbreviation='SE')
+ >>> sweden = Country(name='Sweden', abbreviation='SE')
-3) Let the object validate itself!
+4) Let the object validate itself!
- sweden.name = 5
- # Raises ValueError
+ >>> sweden.name = 5
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "warlock/core.py", line 53, in __setattr__
+ raise InvalidOperation()
+ warlock.core.InvalidOperation
- sweden.overlord = 'Bears'
- # Raises AttributeError
+ >>> sweden.overlord = 'Bears'
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "warlock/core.py", line 53, in __setattr__
+ raise InvalidOperation()
+ warlock.core.InvalidOperation \ No newline at end of file