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
Hi. I have a model named "Product" that has a field "price" of type Decimal with max_digits and decimal_places set to 34 and 18, respectively. when I try to pass the value "9999999999999999.999999999999999999" to it, I encounter the following error:
File "/home/ali/p1/venv/lib/python3.11/site-packages/pydantic/main.py", line 165, in __init__
__pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Product
price
Decimal input should have no more than 16 digits before the decimal point [type=decimal_whole_digits, input_value=Decimal('9999999999999999.999999999999999999'), input_type=Decimal]
For further information visit https://errors.pydantic.dev/2.3/v/decimal_whole_digits
I guess it has something to do with rounding strategy cause it only occurs for this specific number. When I change any of the NINEs (before the decimal point I mean), the error goes away. For example if I pass "9999999999999998.999999999999999999" as price, it works.
Thanks for reporting this. I'm guessing that #7305 is related. @adriangb, what are your thoughts? I know you worked on that previous decimal parsing fix.
Initial Checks
Description
Hi. I have a model named "Product" that has a field "price" of type Decimal with max_digits and decimal_places set to 34 and 18, respectively. when I try to pass the value "9999999999999999.999999999999999999" to it, I encounter the following error:
I guess it has something to do with rounding strategy cause it only occurs for this specific number. When I change any of the NINEs (before the decimal point I mean), the error goes away. For example if I pass "9999999999999998.999999999999999999" as price, it works.
Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: