Advertisement
quantim

WTForm validation problem 2

Jun 30th, 2017
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. from flask_wtf import FlaskForm
  2. from wtforms import TextField, PasswordField, BooleanField
  3. from wtforms.validators import InputRequired, Email, Length, EqualTo, DataRequired, ValidationError
  4.  
  5. # At some point, you may want to simply import wtforms, and then use
  6. # validators.Email, ... for clearer namespacing.
  7.  
  8. class RegistrationForm(FlaskForm):
  9.     username = TextField('username', validators=[InputRequired(message='you forgot your username!'), Length(min=4, max=30)])
  10.     email = TextField('email', validators=[InputRequired(), Email(), Length(max=25)])
  11.     password = PasswordField('password', validators=[InputRequired(), Length(min=8, max=80), EqualTo('confirm', message='Passwords must match')])
  12.     confirm = PasswordField('Repeat Password')
  13.     accept_tos = BooleanField('I accept the TOS', [DataRequired()])
  14.  
  15.  
  16. class LoginForm(FlaskForm):
  17.     username = TextField('username', validators=[InputRequired(), Length(min=4, max=30)])
  18.     password = PasswordField('password', validators=[InputRequired(), Length(min=8, max=80)])
  19.     remember = BooleanField('remember me')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement