#35377 closed New feature (wontfix)
Add past and future validators for Date and DateTime fields
Reported by: | Jasurbek Yuldoshev | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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()
.
Change History (2)
comment:1 by , 7 months ago
Component: | Core (Serialization) → Core (Other) |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
comment:2 by , 7 months ago
Summary: | Add new validators for Date fields in serializers → Add past and future validators for Date and DateTime fields |
---|
Note:
See TracTickets
for help on using tickets.
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 this email thread.
Given the above: