0

I have a problem with a validator. When I'm trying to submit a form with a IntegerField 0 doesn't work,flask yelling This field is requiered. The form:

class Update_vars(FlaskForm):
    start_date = DateField('Start date',validators = [DataRequired()])
    end_date = DateField('End date',validators = [DataRequired()])
    vals_allwd = IntegerField('Values allowed',validators=[DataRequired(),NumberRange(0,10)])

If you encountered this problem and know how to fix it, please let me know. Thanks. Have a great day!

EDIT: I'm thinking that 0 is read as False for DataRequired().

2
  • In fact, the error message depends on the DataRequired validator. If you use InputRequired instead, the problem should not arise.
    – Detlef
    Jun 29, 2022 at 12:22
  • @Detlef that seems to fix my issue. thanks! Jun 29, 2022 at 12:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.