You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IMHO, the provision of a date with dashes and without zero padded month, day values, is valid. python strptime allows this. I agree that this is ambiguous when no dashes are provided.
2024-04-05 00:00:00
Traceback (most recent call last):
File "/tmp/example.py", line 10, in <module>
print(MyModel(dt="2024-4-5"))
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/envs/prod/lib/python3.11/site-packages/pydantic/main.py", line 171, in __init__
self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for MyModel
dt
Input should be a valid datetime or date, input is too short [type=datetime_from_date_parsing, input_value='2024-4-5', input_type=str]
For further information visit https://errors.pydantic.dev/2.6/v/datetime_from_date_parsing
Thanks for the report! Just to clarify - I believe #9227 has been resolved with 2.7.1 - please open a new issue if you're still experiencing problems in that regard!
Closing for now, as I don't think this is a change we're likely to make, given that the desired behavior can easily be achieved with a custom validator. That being said, if this issue gets a bunch of traction / support, we could certainly consider for V3.
sydney-runkle
added
Change
Suggested alteration to pydantic, not a new feature nor a bug
V3
Under consideration for V3
and removed
bug V2
Bug related to Pydantic V2
pending
Awaiting a response / confirmation
labels
Apr 28, 2024
Initial Checks
Description
IMHO, the provision of a date with dashes and without zero padded month, day values, is valid.
python strptime
allows this. I agree that this is ambiguous when no dashes are provided.Example Code
Python, Pydantic & OS Version
Note, I am stuck on an old version awaiting a release with #9227 fixed. My apologies if this issue does not exist with the current release :(
The text was updated successfully, but these errors were encountered: