class FilmValidator(ModelValidator): title = StringField(validators=[validate_not_empty()], required=True) year = IntegerField(required=True) class Meta: messages = { 'title.empty': "\"Название\" не заполнено", 'year.coerce_int': "\"Год выхода\" не заполнено" }
class TestValidator(Validator): bool_field = BooleanField(required=True) decimal_field = DecimalField(required=True) float_field = FloatField(required=True, low=10.0, high=50.0) int_field = IntegerField(required=True) str_field = StringField(required=True) date_field = DateField(required=True, low='jan 1, 2010', high='dec 1, 2010') time_field = TimeField(required=True, low='9 am', high='10 am') datetime_field = DateTimeField(required=True, low='jan 1, 2010', high='dec 1, 2010')
class TestValidator(Validator): field1 = StringField(required=True) field2 = StringField(required=True) field3 = IntegerField(required=True) class Meta: messages = { 'required': 'enter value', 'field2.required': 'field2 required', 'field3.coerce_int': 'pick a number', }
class TestValidator(Validator): float_field = FloatField() int_field = IntegerField(required=True) decimal_field = DecimalField(required=True) boolean_field = BooleanField()
class TestValidator(Validator): int_field = IntegerField(required=True)
class TestValidator(Validator): int_field = IntegerField(validators=[validate_one_of((1, 2, 3))])
class TestValidator(Validator): range1 = IntegerField(low=1, high=5) range2 = IntegerField(low=1, high=5)