示例#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')
     )