[Django] #35377: Add new validators for Date fields in serializers

8 views
Skip to first unread message

Django

unread,
Apr 15, 2024, 11:47:36 AM4/15/24
to django-...@googlegroups.com
#35377: Add new validators for Date fields in serializers
------------------------------------------------+------------------------
Reporter: Jasurbek Yuldoshev | Owner: nobody
Type: New feature | Status: new
Component: Core (Serialization) | Version: 5.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
I often see that validating date fields is quite repetitive, for example
like this:

{{{
def validate_expiration_date(self, value: date) -> date:
if value <= timezone.now().date():
raise serializers.ValidationError("Expiration Date must be in
future")

return value
}}}

I thought maybe it would be good to have such validation rules out of the
box of Django, such as `FutureDateValidator()`, `PastDateValidator()`.
--
Ticket URL: <https://code.djangoproject.com/ticket/35377>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 15, 2024, 1:12:33 PM4/15/24
to django-...@googlegroups.com
#35377: Add new validators for Date fields in serializers
------------------------------------+--------------------------------------
Reporter: Jasurbek Yuldoshev | Owner: nobody
Type: New feature | Status: closed
Component: Core (Other) | Version: 5.0
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Changes (by Natalia Bidart):

* component: Core (Serialization) => Core (Other)
* resolution: => wontfix
* status: new => closed

Comment:

Hello Jasurbek Yuldoshev, thank you for taking the time to create this
ticket.

A very similar idea has been presented and rejected a while ago in
[https://groups.google.com/g/django-
developers/c/LHnM_2jnZOM/m/8-oK6CXyEAAJ this email thread].

Given the above:

* If you are still keen to push this idea forward, the recommended path is
to propose and re-discuss the request with the community and gain
consensus. To do that, please consider starting a new conversation on the
[https://forum.djangoproject.com/c/internals/5 Django Forum], where you'll
reach a wider audience and likely get extra feedback. Please reference the
past conversation that I linked to provide a complete background for the
conversation.
* I'll close the ticket for now, but if there is a community agreement for
this feature request, you are welcome to come back to the ticket and point
to the forum topic, so we can then re-open it. For more details, please
see [https://docs.djangoproject.com/en/stable/internals/contributing/bugs-
and-features/#requesting-features the documented guidelines for requesting
features].
--
Ticket URL: <https://code.djangoproject.com/ticket/35377#comment:1>
Reply all
Reply to author
Forward
0 new messages