예제 #1
0
class AccountSchema(Schema):

    account_id = StringField()
    first_name = StringField()
    last_name = StringField()
    nick_name = StringField()

    #----------------------------------------------------------------------
    @invariant
    def full_name_or_nick_name(self, first_name, last_name, nick_name):
        if (self.first_name.is_defined(first_name) or self.last_name.is_defined(last_name)) \
                and self.nick_name.is_defined(nick_name):
            return 'Specify either full name or nick name'
예제 #2
0
class SubTestSchema(TestSchema):

    description = StringField()
예제 #3
0
class TestSchema(Schema):

    name = StringField()
예제 #4
0
class TestSchema(Schema):

    name = StringField(max_length=32)
    description = NillableField(StringField(min_length=1))
    sub_object = NillableField(SchemaObjectField(SubTestSchema))
예제 #5
0
class SubTestSchema(Schema):

    name = StringField(max_length=32)
예제 #6
0
def test_list_validation_error_type():
    field = ListField(StringField())
    field.validate(FIELD_NAME, TEST_LIST_MIXED)
예제 #7
0
def test_list_validation_index_on_exception():
    field = ListField(StringField())
    try:
        field.validate(FIELD_NAME, TEST_LIST_MIXED)
    except ListFieldInvalidError as e:
        assert e.index == 1
예제 #8
0
def test_list_validation_success_empty():
    field = ListField(StringField())
    field.validate(FIELD_NAME, TEST_LIST_EMPTY)
예제 #9
0
def test_list_validation_success():
    field = ListField(StringField())
    field.validate(FIELD_NAME, TEST_LIST_STRINGS)
예제 #10
0
def test_string_validation_too_long():
    field = StringField(max_length=3)
    field.validate(FIELD_NAME, TEST_STRING)
예제 #11
0
class AccountSchema(Schema):

    name = StringField()
예제 #12
0
def test_string_validation_too_short():
    field = StringField(min_length=12)
    field.validate(FIELD_NAME, TEST_STRING)
예제 #13
0
def test_string_validation_success_w_all_checks():
    field = StringField(min_length=3, max_length=12)
    field.validate(FIELD_NAME, TEST_STRING)
예제 #14
0
def test_string_validation_success_w_min_check():
    field = StringField(min_length=3)
    field.validate(FIELD_NAME, TEST_STRING)
예제 #15
0
def test_string_validation_success_simple():
    field = StringField()
    field.validate(FIELD_NAME, TEST_STRING)
예제 #16
0
class LoginSchema(Schema):

    name = StringField()