def validate_new_password_repeat(form, field):
"""
Validates new password repeat and checks if it matches 'new_password'
:param form: The form which is being passed in
:type form: AccountForm
:param field: The data value for the 'password' entered by User
:type field : PasswordField
"""
if form.email is not None:
# Email form is present, so it's optional
if len(field.data) == 0 and len(form.new_password.data) == 0:
return
if field.data != form.new_password.data:
raise ValidationError('The password needs to match the new '
'password')
评论列表
文章目录