-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforms.py
More file actions
46 lines (40 loc) · 1.4 KB
/
forms.py
File metadata and controls
46 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask_wtf import FlaskForm
from wtforms import (
StringField,
PasswordField,
SubmitField,
IntegerField,
FormField,
FieldList,
Form,
)
from wtforms.validators import DataRequired, Email, EqualTo, Optional, Length, Regexp
class RegistrationForm(FlaskForm):
email = StringField("Email", validators=[DataRequired(), Email()])
password = PasswordField(
"Password",
validators=[
DataRequired(),
Length(min=8, message="Password be at least 8 characters"),
Regexp("^(?=.*[a-z])", message="Password must have a lowercase character"),
Regexp("^(?=.*[A-Z])", message="Password must have an uppercase character"),
Regexp("^(?=.*\\d)", message="Password must contain a number"),
Regexp(
"(?=.*[@$!%*#?&])", message="Password must contain a special character"
),
],
)
password_confirm = PasswordField(
"Confirm Password",
validators=[
DataRequired(),
EqualTo("password", message="Passwords must match"),
],
)
submit = SubmitField("Submit")
class ProductForm(Form):
title = StringField("Title")
price = IntegerField("Price", validators=[Optional()])
class InventoryForm(FlaskForm):
category_name = StringField("Category Name")
products = FieldList(FormField(ProductForm), min_entries=4, max_entries=8)