from flask_wtf import Form
from wtforms import PasswordField
from wtforms.validators import DataRequired, Email, EqualTo, Length
from dmutils.forms import StripWhitespaceStringField


class LoginForm(Form):
    email_address = StripWhitespaceStringField('Email address', validators=[
        DataRequired(message="Email address must be provided"),
        Email(message="Please enter a valid email address")
    ])
    password = PasswordField('Password', validators=[
        DataRequired(message="Please enter your password")
    ])


class EmailAddressForm(Form):
    email_address = StripWhitespaceStringField('Email address', validators=[
        DataRequired(message="Email address must be provided"),
        Email(message="Please enter a valid email address")
    ])


class ChangePasswordForm(Form):
    password = PasswordField('Password', validators=[
        DataRequired(message="Please enter a new password"),
        Length(min=10,
               max=50,
               message="Passwords must be between 10 and 50 characters"
               )
    ])
    confirm_password = PasswordField('Confirm password', validators=[
        DataRequired(message="Please confirm your new password"),
        EqualTo('password', message="The passwords you entered do not match")
    ])


class CreateUserForm(Form):
    name = StripWhitespaceStringField('Your name', validators=[
        DataRequired(message="Please enter a name"),
        Length(min=1,
               max=255,
               message="Names must be between 1 and 255 characters"
               )
    ])

    password = PasswordField('Password', validators=[
        DataRequired(message="Please enter a password"),
        Length(min=10,
               max=50,
               message="Passwords must be between 10 and 50 characters"
               )
    ])

@@ -311,38 +311,41 @@
 ge=%22
-Email address
+You
  must 
-be 
 provide
-d
+ an email address
 %22),%0A
@@ -363,36 +363,40 @@
 il(message=%22
-Please enter
+You must provide
  a valid ema
@@ -499,28 +499,32 @@
 essage=%22
-Please enter
+You must provide
  your pa
@@ -682,38 +682,41 @@
 ge=%22
-Email address
+You
  must 
-be 
 provide
-d
+ an email address
 %22),%0A
@@ -738,28 +738,32 @@
 essage=%22
-Please enter
+You must provide
  a valid
@@ -896,38 +896,40 @@
 quired(message=%22
-Please
+You must
  enter a new pas
@@ -1416,38 +1416,40 @@
 quired(message=%22
-Please
+You must
  enter a name%22),
@@ -1672,22 +1672,24 @@
 essage=%22
-Please
+You must
  enter a

Correct form field validation messages