flaschengeist/geruecht/forms.py

17 lines
549 B
Python

from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField
from wtforms.validators import DataRequired, Length, ValidationError
from geruecht.model import User
class RegistrationForm(FlaskForm):
username = StringField('Name', validators=[DataRequired(), Length(min=2, max=20)])
submit = SubmitField('Create')
def validate_username(self, username):
user = User.query.filter_by(username=username.data).first()
if user:
raise ValidationError('Bist du behindert!? Der Name ist vergeben!!')