class ExtendedRegisterForm(RegisterForm): username = StringField( 'Username', validators=[ validators.length(min=3, max=30), validators.Regexp( r'^[a-zA-Z0-9_-]+$', message= 'Only letters a-z and A-Z, digits and symbols -_ are allowed.') ])
class UserSignupForm(flask_wtf.FlaskForm): localpart = fields.StringField( _('Email address'), [validators.DataRequired(), validators.Regexp(LOCALPART_REGEX)]) pw = fields.PasswordField(_('Password'), [validators.DataRequired()]) pw2 = fields.PasswordField(_('Confirm password'), [validators.EqualTo('pw')]) captcha = flask_wtf.RecaptchaField() submit = fields.SubmitField(_('Sign up'))
class AnyForm(FlaskForm): name = StringField("Name", [validators.InputRequired()]) phone = StringField( "Phone", [validators.InputRequired(), validators.Regexp(r"^\d{4,13}$")]) email = StringField("Email", [validators.InputRequired(), validators.Email()]) submit = SubmitField("Submit")
class RegisterForm(Form): username = StringField('Username', [ validators.Regexp( "^[A-Za-z0-9]*$", message="Username must contain only letters and number"), validators.Length(min=3, max=15) ]) email = StringField('Email', [validators.Length(min=6, max=50)]) password = PasswordField('Password', [ validators.Regexp( "^[A-Za-z0-9]*$", message="Password must contain only letters and number"), validators.Length(min=1, max=10), validators.DataRequired(), validators.EqualTo('confirm', message='Passwords do not match') ]) confirm = PasswordField('Confirm Password')
class InformationForm(Form): username = StringField(label='用户名', validators=[ validators.Regexp(regex=username_regex, message=username_message) ], render_kw={'placeholder': 'Bruce'}, description='2~20字母数字及下划线', id='inputUsername') sex = RadioField(label='性别', validators=[ validators.Regexp(regex=r"^(male|female)$", message='Input error') ], choices=[('male', '男'), ('female', '女')], id='inputSex') email = EmailField(label='电子邮箱', validators=[ validators.Regexp(regex=email_regex, message=email_message) ], render_kw={'placeholder': '*****@*****.**'}, description='电子邮箱', id='inputEmail') birthdate = DateField( label='生日', validators=[validators.DataRequired(message='请输入正确时间格式')], render_kw={'placeholder': '2020-01-01'}, description='出生年月日') check_password = BooleanField(label='是否修改密码', id="inputCheckbox") password = PasswordField( label='新密码', validators=[validators.EqualTo('confirm', message=confirm_message)], description='8~16字母数字', id='inputPassword') confirm = PasswordField(label='确认密码', description='再次输入密码', id='inputConfirm') def validate_password(self, field): if 'checked' in str(self.check_password) and re.match( password_regex, field.data) is None: raise ValidationError(password_message)
class UserForm(flask_wtf.FlaskForm): localpart = fields.StringField(_('E-mail'), [validators.DataRequired(), validators.Regexp(LOCALPART_REGEX)]) pw = fields.PasswordField(_('Password'), [validators.DataRequired()]) pw2 = fields.PasswordField(_('Confirm password'), [validators.EqualTo('pw')]) quota_bytes = fields_.IntegerSliderField(_('Quota'), default=1000000000) enable_imap = fields.BooleanField(_('Allow IMAP access'), default=True) enable_pop = fields.BooleanField(_('Allow POP3 access'), default=True) comment = fields.StringField(_('Comment')) enabled = fields.BooleanField(_('Enabled'), default=True) submit = fields.SubmitField(_('Save'))
class Registration(Form): user = StringField('username:'******'用户名长度有问题')]) passwd = StringField('password:'******'输入长度有问题'), validators.Regexp( regex="^(?=.*[a-z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}", message='密码至少8位,包含字母,特殊字符和数字') ]) accept_rules = BooleanField('我同意此协议', [validators.InputRequired()])
class BlogPostForm(FlaskForm): title = StringField(label='Title', validators=[ validators.Length(min=4, max=140), ]) text = StringField(label='Article Text', validators=[ validators.Length(min=10, max=3500), ]) author = StringField(label='Author', validators=[ validators.Length(min=2, max=25), validators.Regexp('\w+\s\w+', message='You should enter your name and last name') ])
def conv_String(self, model, field, kwargs): if field.regex: kwargs['validators'].append(validators.Regexp(regex=field.regex)) self._string_common(model, field, kwargs) if 'password' in kwargs: if kwargs.pop('password'): return f.PasswordField(**kwargs) if field.max_length: return f.StringField(**kwargs) return f.TextAreaField(**kwargs)
class SettingsForm(Form): first_name = TextField('first_name', [validators.Required()]) last_name = TextField('last_name', [validators.Required()]) sex_code = IntegerField('sex_code', [validators.AnyOf(message="Sorry you can only choose male or female", values=[0,1])]) phone = TextField('phone', [ validators.Optional(), validators.Regexp("^(?:\([2-9]\d{2}\)\ ?|[2-9]\d{2}(?:\-?|\ ?))[2-9]\d{2}[- ]?\d{4}$", message="Not valid phone number (xxx-xxx-xxxx)") ]) bio = TextField('bio')
class AliasForm(flask_wtf.FlaskForm): localpart = fields.StringField( _('Alias'), [validators.DataRequired(), validators.Regexp(LOCALPART_REGEX)]) wildcard = fields.BooleanField( _('Use SQL LIKE Syntax (e.g. for catch-all aliases)')) destination = DestinationField(_('Destination')) comment = fields.StringField(_('Comment')) submit = fields.SubmitField(_('Save'))
class RegisterForm(Form): email = StringField('Email', [ validators.DataRequired(), validators.Regexp('(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)', message="Enter valid email address") ]) password = PasswordField('Password', [ validators.DataRequired(), validators.EqualTo('confirm', message='Password do not match') ]) confirm = PasswordField('Confirm Password')
class QueryForm(Form): start_date = TextField('Start date:', validators=[ validators.required(), validators.Regexp( '(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})$', flags=0, message=None) ]) end_date = TextField('End date:', validators=[ validators.required(), validators.Regexp( '(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})$', flags=0, message=None) ]) src_ip4 = TextField( 'Source IP:', validators=[validators.optional(), validators.Length(min=5, max=45)]) dst_ip4 = TextField( 'Destination IP:', validators=[validators.optional(), validators.Length(min=5, max=45)]) protocol = RadioField('Protocol:', choices=[('all', 'All'), ('tcp', 'TCP'), ('udp', 'UDP')], default='All', validators=[validators.required()]) def validate(self): if not super(QueryForm, self).validate(): return False if not self.src_ip4.data and not self.dst_ip4.data: msg = 'At least one of Source and Destination IP must be set' self.src_ip4.errors.append(msg) self.dst_ip4.errors.append(msg) return False return True
class SendSMSForm(Form): firstname = StringField('First Name', [ validators.Regexp( '^[a-zA-Z\s]*$', message="**First Name can only contain letters or space"), validators.Length( min=1, max=25, message="**First Name must be between 1 & 25 characters") ]) lastname = StringField('Last Name', [ validators.Regexp( '^[a-zA-Z\s]*$', message="**Last Name can only contain letters or space"), validators.Length( min=1, max=25, message="**Last Name must be between 1 & 25 characters") ]) phonenumber = StringField('Phone Number', [ validators.Regexp('^(\+0?1\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$', message="**Please Enter a valid US number") ]) mobile_carrier = SelectField( 'Cell Phone Carrier', choices=[('@txt.att.net', 'AT&T'), ('@tmomail.net', 'T-Mobile'), ('@vzwpix.com', 'Verizon'), ('@pm.sprint.com', 'Sprint'), ('@mypixmessages.com', 'XFinity Mobile'), ('@vmpix.com', 'Virgin Mobile'), ('@mmst5.tracfone.com', 'Tracfone'), ('@mymetropcs.com', 'Metro PCS'), ('@myboostmobile.com', 'Boost Mobile'), ('@tmomail.net', 'Mint Mobile'), ('@mms.cricketwireless.net', 'Cricket'), ('@text.republicwireless.com', 'Republic Wireless'), ('@msg.fi.google.com', 'Google Fi (Project Fi)'), ('@mms.uscc.net', 'U.S. Cellular'), ('@message.ting.com', 'Ting'), ('@mailmymobile.net', 'Consumer Cellular'), ('@cspire1.com', 'C-Spire'), ('@vtext.com', 'Page Plus')], default=("N/A", "N/A")) message_content = TextAreaField('Message Content')
class ValidacionLogin(Form): email = StringField( "email", [ validators.Regexp( r'^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})$', message="email invalido") # noqa E501 ]) password = StringField("password", [validators.InputRequired(message=requerido)])
class CategoryForm(Form): name = StringField('Name <span class="text-danger">*</span>', [ validators.Regexp( '\w+$', message="Name must contain only letters numbers or underscore"), validators.Length(min=2, max=25) ]) alias = StringField('Alias', [validators.Length(min=0, max=25)]) description = TextAreaField('Description', [validators.Length(min=0, max=200)]) parent = SelectField('Parent category', coerce=int)
class RegisterForm(Form): name = StringField('Name', [validators.Length(min=1, max=200)]) username = StringField('Username', [validators.Length(min=4, max=200)]) email = StringField('Email', [ validators.Regexp(r"^[a-z0-9_-]+@[a-z0-9_-]+\.[a-z]{2,10}$", message="Invalid Email") ]) password = PasswordField('Password', [validators.DataRequired()]) confirm = PasswordField( 'Confirm Password', [validators.EqualTo('password', message="Passwords do not match")])
class ArtifactSubmit(Form): """ """ cves = fields.StringField('CVE(s)', validators=[ validators.Regexp( '^CVE-\d+-\d+(\s*,\s*CVE-\d+-\d+)*$', message='Invalid CVE. Multiple CVEs can seperated with commas.' ), validators.required(), ]) archive = fields.FileField('Archive')
class PostForm(Form): post_id = IntegerField('Номер допису: ') post_type = StringField('Тип допису (скарга чи пропозиція): ', [validators.Regexp(regex='скарга|пропозиція')]) post_text = StringField("Текст допису: ", [ validators.DataRequired("Текст допису (від 3 до 1000 символів)"), validators.Length(3, 1000, "Текст допису (від 3 до 1000 символів)") ]) stud_id = StringField( 'Номер заліковки (в форматі 113ХХХ): ', [validators.Regexp(regex='^[1][1][3][0-9][0-9][0-9]$')]) disc_id = IntegerField("Номер дисципліни: ", [ validators.DataRequired("Введіть номер дисципліни"), ]) submit = SubmitField("Save")
class ProfileForm(flask_wtf.Form): login = wtforms.StringField('Login') email = wtforms.StringField('Email') name = wtforms.StringField('Name', validators=[ validators.Required(), validators.Length(1, 64), validators.Regexp(r'^[A-Za-z0-9_\- ]+$', 0, 'Name must have only letters, numbers, spaces, dots, dashes or underscores')]) submit = wtforms.SubmitField('Update')
class DnsSpoofingForm(Form): target_url = StringField('Target URL', validators=[validators.DataRequired()]) spoof_ip = StringField( 'Spoof IP', validators=[ validators.DataRequired(), validators.Regexp( '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$', message="Invalid IP Format") ])
class UserForm(FlaskForm): username = TextField('用户名:', [validators.Required('修改用户名时请勿输入空的用户名')]) age = IntegerField('年龄:', [validators.Required('修改年龄时请勿输入空的年龄')]) email = TextField('电子邮件:', [validators.Email('Email格式不正确')]) telphone = TextField('联系电话:', [ validators.Required('修改联系电话时请勿输入空的联系电话'), validators.Regexp('^[0-9]{11}$', message='联系电话格式有误') ]) date = TextField('注册时间:') update = SubmitField('提交修改') loginout = SubmitField('退出登录')
class SiteCreationForm(Form): shrt_link_regex = "^[a-z0-9_\-]*$" shrt_validation_err = "Invalid input. Accepted Characters: a-z,-,_,0-9" shrt = StringField("go/", [ validators.Regexp( shrt_link_regex, flags=0, message=shrt_validation_err), validators.DataRequired(message="Field cannot be empty") ]) url = StringField("URL: ", [validators.URL(require_tld=False)])
class SubmitFormForm(Form): picture = StringField( 'Picture (Link hosted)', [validators.url(message='Please enter a valid image URL')]) name = StringField('Name', [validators.Length(min=1, max=50)]) email = StringField('Email', [validators.email()]) phone = StringField('Phone #', [ validators.Regexp('^[2-9]\\d{2}-\\d{3}-\\d{4}$', message="Enter a valid phone number: XXX-XXX-XXXX") ]) school = StringField('School', [validators.DataRequired()])
class ShortenForm(FlaskForm): url = StringField('url', validators=[validators.input_required()]) shorturl = StringField( 'shorturl', validators=[ validators.optional(), validators.Regexp( r'^[{chars}]{{,23}}$'.format(chars=BASE36_CHARS), message=('Make sure the `shorturl` field is no more than 23 ' 'alphanumeric chars.')) ])
class BankForm(Form): bankname=TextField("Name of Bank", [validators.Required("Please enter bank name")]) name=TextField("Name on card", [validators.Required("Please enter name.")]) cardno=TextField("Card Number", [validators.Required("Please enter card number."),validators.Length(min=16, max=19),validators.Regexp('^(?:4[0-9]{12}(?:[0-9]{3})?|(?:5[1-5][0-9]{2}| 222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12}|(?:2131|1800|35\d{3})\d{11})$', message="Not a Credit/Debit card number")]) expire=TextField("Expiry Date", [validators.Required("Please enter expire."),validators.Regexp('^((1)([0-2]{1})|[1-9]{2})[/]20([0-9]{2})$', message="Enter date in format MM/20YY")]) ccv=TextField("Security Number", [validators.Required("Please enter security code."),validators.Length(min=3, max=3,message="The ccv must be of length 3")]) def validate(self): if not Form.validate(self): return False else: return True
class LoginSignupForm(Form): email = StringField('Email', [ validators.Regexp( r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)'), validators.Email(), validators.DataRequired() ]) password = PasswordField( 'Password', [validators.Length(min=7, max=50), validators.DataRequired()])
class ShotParamsForm(Form): id = HiddenField() exposure = TextAreaField( "Exposure", description= "List of exposure values ranging from 0-33342 uS. one value per line", default="15000", validators=[ validators.Regexp('\d*([\r\n]|$)', message="Only numbers on a single line") ]) gain = TextAreaField( "Gain", default="0", description= "List of gain values from -89 to 593, one value per line, a single value applies to all exposures", validators=[ validators.Regexp('\d*([\r\n]|$)', message="Only numbers on a single line") ])
def conv_String(self, model, field, kwargs): if field.regex: kwargs["validators"].append(validators.Regexp(regex=field.regex)) self._string_common(model, field, kwargs) password_field = kwargs.pop("password", False) textarea_field = kwargs.pop("textarea", False) or not field.max_length if password_field: return f.PasswordField(**kwargs) if textarea_field: return f.TextAreaField(**kwargs) return f.StringField(**kwargs)
class SaleForm(FlaskForm): upc_code = StringField( "UPC: ", validators=[DataRequired(message="This field can not be empty")]) #validators.Regexp(r'(^\d{12}$)', # message="Incorrect upc code format, 12 digits expected")]) quantity = StringField( "Quantity: ", validators=[ DataRequired(message="This field can not be empty"), validators.Regexp(r'^\d+$') ]) check_number = StringField( "Check number: ", validators=[ DataRequired(message="This field can not be empty"), validators.Regexp(r'^\d+$') ], render_kw={'readonly': True})