-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error serializing MaxValueValidator.limit_value of type datetime.timedelta #388
Comments
hi @voyc-jean, nice catch! yes that is a bug. i had a quick look into it and found that DRF's so you would get total seconds from DRF without further modification. for parity we should probably do the same for yaml. furthermore, i think we should introduce a hook into our |
this should get rid of the exception but i think we have one issue left. the validator fills |
Hi @tfranzel, Thanks a lot for the quick solution! I can confirm that this gets rid of the exception, though after looking into this further I think there might be more to the issue. I've just tested this and you're correct that DRF's However, the DRF Values are parsed back from 'duration strings' to timedelta by DRF's I think the schema (including the minimum / maximum) should reflect the same? Thanks. |
ok so to summarize. depending on how one would go through the code, you could end up with
the real issue i see is that bummer! the least broken thing could be to remove it altogether for non-numbers. |
I see this has been fixed now in release 0.17.0, thanks @tfranzel! Regarding the |
you're welcome! i think we can reuse this issue, as it is still closely related to the remaining issue. |
had the exact same thought yesterday. 👍 thx |
Hi, I'm using drf's |
@dirodriguezm please post a code example. |
closing this issue for now. feel free to comment if anything is missing or not working and we will follow-up. @dirodriguezm feel free to open a new issue if your problem persists. |
Describe the bug
Similar to #357, the yaml renderer is unable to serialize a
MaxValueValidator.limit_value
of typedatetime.timedelta
.Using the JSON renderer solves the issue.
To Reproduce
Add a
MaxValueValidator
to a model field with alimit_value
type ofdatetime.timedelta
:Raised exception:
Expected behavior
The yaml render should be able to serialize
datetime.timedelta
values.The text was updated successfully, but these errors were encountered: