-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
pydantic/pydantic-core
#1269Labels
bug V2Bug related to Pydantic V2Bug related to Pydantic V2
Milestone
Description
Initial Checks
- I confirm that I'm using Pydantic V2
Description
This seems to be a regression as v.2.6.4 was not affected by this problem.
Basically if you define a model with an integer field and fill it with string "00", you get the following error message:
pydantic_core._pydantic_core.ValidationError: 1 validation error for MyModel
id
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='00', input_type=str]
For further information visit https://errors.pydantic.dev/2.7/v/int_parsing
The problem seems only to happen with multiple zeros (i.e. "00", "000", ...), other numeric strings work properly (e.g. "01", "0").
Example Code
from pydantic import BaseModel
class User(BaseModel):
id: int = 0
s = User(id="01") # works
print(s)
s = User(id="00") # fails
print(s)
Python, Pydantic & OS Version
pydantic version: 2.7.0
pydantic-core version: 2.18.1
akrherz
Metadata
Metadata
Assignees
Labels
bug V2Bug related to Pydantic V2Bug related to Pydantic V2