def valid_password(form, field):
"""
Function to check for validity of a password
:param form: The form which is being passed in
:type form: Form
:param field: The data value for the 'password' inserted by User
:type field : PasswordField
"""
if len(field.data) == 0:
raise ValidationError('new password cannot be empty')
if len(field.data) < 10 or len(field.data) > 500:
raise ValidationError('Password needs to be between 10 and 500 '
'characters long (you entered %s characters'
% len(field.data))
评论列表
文章目录