Exemplo n.º 1
0
class TestArrayType(TestTypes, unittest.TestCase):
    schema = (jsd.Array(min_items=0, item_type=jsd.String(required=True))
              .json())
    expected_schema = {
        'type': ['array', 'null'],
        'minItems': 0,
        'items': {'type': 'string'},
    }

    valid_input = (
        [],
        ['a string'],
    )
    invalid_input = (
        [0],
        ['a string', 0],
        [None],
    )
Exemplo n.º 2
0
 class Stuff(jsd.Object):
     name = jsd.String(required=True)
     email = jsd.String()
     groups = jsd.Array(min_items=1, item_type=jsd.String(required=True))
Exemplo n.º 3
0
class TestStringTypeRequired(TestTypes, unittest.TestCase):
    schema = jsd.String(required=True).json()
    expected_schema = {'type': 'string'}

    valid_input = ['a string']
    invalid_input = [None]
Exemplo n.º 4
0
class TestStringType(TestTypes, unittest.TestCase):
    schema = jsd.String().json()
    expected_schema = {'type': ['string', 'null']}

    valid_input = ['a string', None]
    invalid_input = [0, .1, [], {}]
Exemplo n.º 5
0
 class Example(jsd.Object):
     thing = jsd.OneOf(jsd.String(),
                       jsd.Boolean(required=True))
Exemplo n.º 6
0
class NestedStuff(jsd.Object):
    name = jsd.String(required=True)
    email = Email()
    groups = jsd.Array(item_type=jsd.String(), required=True)
Exemplo n.º 7
0
class Email(jsd.Object):
    service = jsd.String()
    value = jsd.String()