Guest User

Untitled

a guest
Nov 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.41 KB | None | 0 0
  1.     Doc(Field('cpf', Cpf())).validate({'cpf': '054.405.097-55'})
  2.     d = Doc(
  3.         StaticField('type', 'test'),
  4.         OptionField('blaz', ['001', '002']),
  5.         Field('foo', Cpf()),
  6.         Field('bar', String()),
  7.         Field('baz', Doc(
  8.                 Field('blub', Number()),
  9.                 Field('qux', Array(Number())),
  10.             )
  11.         )
  12.     )
  13.     d.validate({'blaz': '001', 'foo':u'081.847.845-46', 'bar': 'baz', 'type': 'test', 'baz': {'blub': 1, 'qux': [1, 2]}})
  14.    
  15.     Doc(
  16.         Field('left', Recursive()),
  17.         Field('value', Number()),  
  18.         Field('right', Recursive())
  19.     ).validate({
  20.         'value': 10,
  21.         'left': {
  22.             'value': 5,
  23.             'left': {'value': 2},
  24.             'right': {'value': 6, 'right': {'value': 7}}
  25.         }
  26.     })
  27.        
  28.     Doc(
  29.         Field('subject', String()),
  30.         Field('body', String()),
  31.         Field('replies', Array(Recursive()))
  32.     ).validate({
  33.         'subject': 'Couch rulez',
  34.         'body': '... and yet I suck',
  35.         'replies': [
  36.             {
  37.                 'subject': 'Re: Couch rulez',
  38.                 'body': 'this!',
  39.                 'replies': [{'subject': 'Re: Re: Couch rulez', 'body': 'Totally', 'replies':[]}]
  40.             },
  41.             {
  42.                 'subject': 'Spam',
  43.                 'body': 'Buy something crappy',
  44.                 'replies': []
  45.             }
  46.         ]
  47.     })
Add Comment
Please, Sign In to add comment