Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"DateField in WTForms triggers 'Not a valid date value' error when left empty, even with no validators" #614

Open
feiticeir0 opened this issue Nov 4, 2024 · 0 comments

Comments

@feiticeir0
Copy link

Description of the Problem:
The DateField in WTForms triggers a 'Not a valid date value' validation error when left empty, even if no validators are specified. This behavior prevents the field from being optional and can result in unexpected validation failures.

Reproduction Steps:

  1. Create a FlaskForm with a DateField and no validators.
  2. Submit the form with the DateField left empty.
  3. Observe that the field triggers a validation error.

Expected Behavior:
The DateField should pass validation when empty, as no validators are present to enforce input.

Environment Details:

  • WTForms version: 3.2.1
  • Flask version: 3.0.3
  • Python version: 3.12.3

Code Example:

class ExampleForm(FlaskForm):
    date_field = DateField('Date', format='%Y-%m-%d', validators=[])

@app.route('/test', methods=['GET', 'POST'])
def test_view():
    form = ExampleForm()
    if form.validate_on_submit():
        return 'Form submitted successfully!'
    return render_template('test.html', form=form)```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant