From 24657e1fff1a7a0d98388c9e9495e99e19e130c9 Mon Sep 17 00:00:00 2001 From: mazzolaa <59713660+mazzolaa@users.noreply.github.com> Date: Mon, 6 Dec 2021 02:19:09 -0500 Subject: [PATCH] Added Length validator Added wtforms Length validator. Applied this validator to the bill amount because large values will crash an instance of the project. --- ihatemoney/forms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ihatemoney/forms.py b/ihatemoney/forms.py index 4e241c86..f1ca2560 100644 --- a/ihatemoney/forms.py +++ b/ihatemoney/forms.py @@ -20,6 +20,7 @@ from wtforms.validators import ( NumberRange, Optional, ValidationError, + Length, ) from ihatemoney.currency_convertor import CurrencyConverter @@ -305,7 +306,7 @@ class BillForm(FlaskForm): date = DateField(_("When?"), validators=[DataRequired()], default=datetime.now) what = StringField(_("What?"), validators=[DataRequired()]) payer = SelectField(_("Who paid?"), validators=[DataRequired()], coerce=int) - amount = CalculatorStringField(_("How much?"), validators=[DataRequired()]) + amount = CalculatorStringField(_("How much?"), validators=[DataRequired(), Length(max=20)]) currency_helper = CurrencyConverter() original_currency = SelectField(_("Currency"), validators=[DataRequired()]) external_link = URLField(