Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Doc(Field('cpf', Cpf())).validate({'cpf': '054.405.097-55'})
- d = Doc(
- StaticField('type', 'test'),
- OptionField('blaz', ['001', '002']),
- Field('foo', Cpf()),
- Field('bar', String()),
- Field('baz', Doc(
- Field('blub', Number()),
- Field('qux', Array(Number())),
- )
- )
- )
- d.validate({'blaz': '001', 'foo':u'081.847.845-46', 'bar': 'baz', 'type': 'test', 'baz': {'blub': 1, 'qux': [1, 2]}})
- Doc(
- Field('left', Recursive()),
- Field('value', Number()),
- Field('right', Recursive())
- ).validate({
- 'value': 10,
- 'left': {
- 'value': 5,
- 'left': {'value': 2},
- 'right': {'value': 6, 'right': {'value': 7}}
- }
- })
- Doc(
- Field('subject', String()),
- Field('body', String()),
- Field('replies', Array(Recursive()))
- ).validate({
- 'subject': 'Couch rulez',
- 'body': '... and yet I suck',
- 'replies': [
- {
- 'subject': 'Re: Couch rulez',
- 'body': 'this!',
- 'replies': [{'subject': 'Re: Re: Couch rulez', 'body': 'Totally', 'replies':[]}]
- },
- {
- 'subject': 'Spam',
- 'body': 'Buy something crappy',
- 'replies': []
- }
- ]
- })
Add Comment
Please, Sign In to add comment