Sanic 表单验证静默失败

Sanic Form Validation Failing Silently

大家好,我正在使用带有 WTForms 和 Sanic-WTF 的 Sanic。我的 SignUpForm 有以下代码:

class SignUpForm(SanicForm):
    email = EmailField('Email', validators=[DataRequired(), Email()])
    password = PasswordField('Password', validators=[DataRequired(), 
    Length(min=3, max=25), EqualTo('confirm_password', message='Passwords must match.')])
    confirm_password = PasswordField('Confirm Password', validators=[DataRequired()])

我也有这个作为我在 Class 基于视图中验证的验证。

async def post(self, request):
    form = SignUpForm(request)
    email = form.email.data
    print(email)
    email_exists = await unique_db(email)
    print(form.errors)
    print ('Form validated: {}, Email Exists: {}'.format(form.validate_on_submit(), email_exists))
    if form.validate_on_submit() and email_exists == False:
        print('Validated')
        await app.db.user_details.update_one({'user':'details'},{'$set': data}, upsert=True)
        return json({'success':True})
    return template('signup.html', form=form)

我不知道发生了什么。我也试过 form.validate() 我的注册表单是

<form name="SignupForm" style="padding-top: 50px;" method="post">
  {{ form.csrf_token }}
  <div class="row justify-content-center">
    <div class="col-lg-8 col-md-10 col-sm-12">
      <div class="card">
        <div class="card-body">
          <h3 class="card-title">Sign up</h3>
            {{ macros.render_field(form.email, label_visible=true, placeholder='Email', type='email') }}
            <small id="passwordHelpBlock" class="form-text text-muted">Your email must be in the form name@example.com</small>
            {{ macros.render_field(form.password, label_visible=true, placeholder='Password', type='password') }}
            {{ macros.render_field(form.confirm_password, label_visible=true, placeholder='Confirm Password', type='password') }}
            <button type="submit" class="btn btn-success" id="login-submit-button">Submit</button>
        </div>
        <div class="card-footer text-muted text-center">
          Already have an account? <a href="/login">Log in</a>
        </div>
      </div>
    </div>
  </div>
</form>

好吧,他们似乎是 SanicForm 中的一个错误,因为当我将我的 SignUpForm class 更改为继承自 Form(通用 WTForm 表单 class)时,它工作正常。