Пример #1
0
def test_enum_validation():
    validator = validators.Enum('cat', 'dog', 'fish')

    validator.validate('cat')
    validator.validate('dog')
    validator.validate('fish')

    with pytest.raises(errors.ValidationError):
        validator.validate('horse')
Пример #2
0
 class Person(models.Base):
     handness = fields.StringField(
         validators=validators.Enum('left', 'right')
     )
Пример #3
0
 class Person(models.Base):
     handness = fields.StringField(
         help_text="The person's favorite hand.",
         validators=validators.Enum('left', 'right')
     )