DecimalField raise exception if min_value
is set and input data is empty string
#8872
Unanswered
msscaroso
asked this question in
Potential Issue
Replies: 1 comment
-
The line where the exception happens is part of the django project (https://docs.djangoproject.com/en/4.1/_modules/django/core/validators/#MinValueValidator) But I think the django validator expects this value to be already cleaned. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
First of all, thank you for the amazing framework. I have been using it since I started to work as a developer and it really helps me on a day to day basis.
I'm raising a potential issue and, if confirmed that it's actually an issue, I'm more than happy to work on a patch !
Consider the example below:
As we can see, the first serializer considers the empty string a valid value. Maybe someone can disagree with this behavior, but it's not the point.
But if I declare the same serializer, but adding a
min_value=0
constraint in the DecimalField it throws the following exception:I believe it should either consider the blank string as invalid or handle it. But throwing an exception should not happen.
Tested this with 3.12.4
Beta Was this translation helpful? Give feedback.
All reactions