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')
class Person(models.Base): handness = fields.StringField( validators=validators.Enum('left', 'right') )
class Person(models.Base): handness = fields.StringField( help_text="The person's favorite hand.", validators=validators.Enum('left', 'right') )