I have the following model in pydantic (Version 2.0.3)
from typing import Tuple
from pydantic import BaseModel
class Model(BaseModel):
test_field: Tuple[int]
But when I enter
model = Model(test_field=(1,2))
I get as error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "/Users/tobi/Documents/scraiber/z_legacy/fastapi_test_app/venv/lib/python3.10/site-packages/pydantic/main.py", line 150, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Model
test_field
Tuple should have at most 1 item after validation, not 2 [type=too_long, input_value=(1, 2), input_type=tuple]
For further information visit https://errors.pydantic.dev/2.0.3/v/too_long
Do you know how I can fix that?