form.py
from flask_wtf import FlaskForm
from wtforms import StringField, PasswordField, BooleanField, IntegerField,
TextAreaField, SubmitField, MultipleFileField
from wtforms.validators import DataRequired, Length, ValidationError, Email
custom validator
class FortyTwoForm(FlaskForm):
answer = IntegerField('The Number')
submit = SubmitField()
def validate_answer(form, field):
if field.data != 42:
raise ValidationError('Must be 42.')