Skip to content

Commit

Permalink
fix(form,organism): bad "code_postal" returned a flask error. add val…
Browse files Browse the repository at this point in the history
…idator in the wtforms
  • Loading branch information
jacquesfize committed Nov 13, 2024
1 parent 8e3bd2f commit 63a380c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/bib_organismes/forms.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from flask_wtf import FlaskForm
from wtforms import (
StringField,
PasswordField,
BooleanField,
SubmitField,
HiddenField,
SelectField,
validators,
)
from wtforms.validators import DataRequired, Email

# from wtforms_components import IntergerField

def validate_code_postal(form, field):
if len(field.data) != 5:
raise validators.ValidationError(
"Le code postal renseigné comporte plus/moins de 5 caractères"
)


class Organisme(FlaskForm):
Expand All @@ -23,7 +25,7 @@ class Organisme(FlaskForm):
validators=[DataRequired(message="Le nom de l'organisme est obligatoire")],
)
adresse_organisme = StringField("Adresse")
cp_organisme = StringField("Code Postal")
cp_organisme = StringField("Code Postal", validators=[validate_code_postal])
ville_organisme = StringField("Ville")
tel_organisme = StringField("Téléphone")
fax_organisme = StringField("Fax")
Expand Down

0 comments on commit 63a380c

Please sign in to comment.