16 lines
626 B
Python
16 lines
626 B
Python
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, DecimalField, IntegerField
|
|
from wtforms.validators import DataRequired, Length, NumberRange
|
|
|
|
class ProductForm(FlaskForm):
|
|
name = StringField('商品名稱', validators=[
|
|
DataRequired(message='請輸入商品名稱'),
|
|
Length(max=100, message='商品名稱不能超過100個字符')
|
|
])
|
|
price = DecimalField('單價', validators=[
|
|
DataRequired(message='請輸入單價')
|
|
])
|
|
min_quantity = IntegerField('安全庫存量', validators=[
|
|
NumberRange(min=0, message='安全庫存量不能小於0')
|
|
], default=0)
|