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:
- Create a
FlaskForm with a DateField and no validators.
- Submit the form with the
DateField left empty.
- 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)```