Fix missing quotes and make spacing more standard
This commit is contained in:
@@ -23,7 +23,7 @@ serialization might look something like this:
|
||||
'age': '20',
|
||||
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
|
||||
'phones': [{'location': 'home', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
|
||||
Let's further imagine you'd like to make sure, on demand, that a
|
||||
@@ -416,7 +416,7 @@ Deserializing A Valid Serialization
|
||||
'age': '20',
|
||||
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
|
||||
'phones': [{'location': 'home', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
schema = Person()
|
||||
deserialized = schema.deserialize(cstruct)
|
||||
@@ -433,7 +433,7 @@ conforms to the schema, ``deserialized`` will be the following:
|
||||
'age': 20,
|
||||
'friends': [(1, 'jim'), (2, 'bob'), (3, 'joe'), (4, 'fred')],
|
||||
'phones': [{'location': 'home', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
|
||||
Note that all the friend rankings have been converted to integers,
|
||||
@@ -459,7 +459,7 @@ validation error?
|
||||
'age': '-1',
|
||||
'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')],
|
||||
'phones': [{'location': 'bar', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
schema = Person()
|
||||
schema.deserialize(cstruct)
|
||||
@@ -473,7 +473,7 @@ It will print something like:
|
||||
|
||||
Invalid: {'age': '-1 is less than minimum value 0',
|
||||
'friends.1.0': '"t" is not a number',
|
||||
'phones.0.location:'"bar" is not one of "home", "work"'}
|
||||
'phones.0.location': '"bar" is not one of "home", "work"'}
|
||||
|
||||
The above error is telling us that:
|
||||
|
||||
@@ -498,7 +498,7 @@ dictionary:
|
||||
'age': '-1',
|
||||
'friends': [('1', 'jim'), ('t', 'bob'), ('3', 'joe'), ('4', 'fred')],
|
||||
'phones': [{'location': 'bar', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
schema = Person()
|
||||
try:
|
||||
@@ -514,7 +514,7 @@ This will print something like:
|
||||
|
||||
{'age': '-1 is less than minimum value 0',
|
||||
'friends.1.0': '"t" is not a number',
|
||||
'phones.0.location:'"bar" is not one of "home", "work"'}
|
||||
'phones.0.location': '"bar" is not one of "home", "work"'}
|
||||
|
||||
:exc:`colander.Invalid` Exceptions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1053,7 +1053,7 @@ a schema created declaratively:
|
||||
'age': '20',
|
||||
'friends': [('1', 'jim'), ('2', 'bob'), ('3', 'joe'), ('4', 'fred')],
|
||||
'phones': [{'location': 'home', 'number': '555-1212'},
|
||||
{'location':'work', 'number':'555-8989'},],
|
||||
{'location': 'work', 'number': '555-8989'}],
|
||||
}
|
||||
deserialized = schema.deserialize(data)
|
||||
|
||||
@@ -1102,4 +1102,3 @@ module scope before mutating any of its subnodes:
|
||||
:meth:`colander.SchemaNode.clone` clones all the nodes in the schema,
|
||||
so you can work with a "deep copy" of the schema without disturbing the
|
||||
"template" schema nodes defined at a higher scope.
|
||||
|
||||
|
Reference in New Issue
Block a user