Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#1070 closed defect (fixed)

Need to improve date validation

Reported by: leopold@… Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

when I input a invalid date, for example 0256-02-02, this date unexpectedly pass the validation of date field.
because the _datere = r'\d{4}-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))' " in validators.py don't forbid the invalid year number. this will lead to error message "year=256 is before 1900; the datetime strftime() methods require year >= 1900" . since django don't support small-number year, date validation should answer for this . I think
_datere = r'()((?:19[0-9]{2}|[2-9][0-9]{3}))-((?:0?[1-9])|(?:1[0-2]))-((?:0?[1-9])|(?:[12][0-9])|(?:3[0-1]))' to forbid invalid input or just change 'isValidaANSIDate' to replay the small-number year of error message.
At last, I wish django can replace hardcode of date and time format with variable in setting file, that will be more convient for changing output format of date field, thanks.

Change History (1)

comment:1 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [2134]) Fixed #1070 -- Improved date validation to limit it to dates 1900 and up.

Note: See TracTickets for help on using tickets.
Back to Top