From a22a9f91995a4892acad90d9643f0d0b159f2304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20=27Necoro=27=20Neumann?= Date: Fri, 24 Jul 2020 19:13:48 +0200 Subject: length validators for string fields --- kosten/app/forms.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'kosten/app/forms.py') diff --git a/kosten/app/forms.py b/kosten/app/forms.py index 9bab284..818384d 100644 --- a/kosten/app/forms.py +++ b/kosten/app/forms.py @@ -31,6 +31,10 @@ class MonthField(HTML4DateField): req = [validators.input_required()] +def lenOf(col): + if hasattr(col.type, 'length') and col.type.length: + return [validators.length(max = col.type.length)] + class Form(FlaskForm): class Meta: locales = False -- cgit v1.2.3