Bug Tracker

Ticket #2682 (new enhancement)

Opened 9 months ago

Last modified 8 months ago

[validate] Better ISO date and time validation

Reported by: DThrasher Assigned to: joern
Type: enhancement Priority: minor
Milestone: 1.2.4 Component: plugin
Version: 1.2.3 Keywords: validate
Cc: Needs: Review

Description (last modified by joern) (diff)

I have a few suggestions for enhancing the ISO date and time RegEx? expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87.

ISO date
^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$
ISO time
^([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?$
ISO offset
^([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?$
ISO date and time
^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?)?$
ISO Date, time and offset (the works)
^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?)?$

Attachments

Change History

Changed 8 months ago by joern

  • description changed from I have a few suggestions for enhancing the ISO date and time RegEx expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87. ISO date ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$ ISO time ^([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?$ ISO offset ^([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?$ ISO date and time ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?)?$ ISO Date, time and offset (the works) ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?)?$ to I have a few suggestions for enhancing the ISO date and time RegEx expressions. I modified a few examples I found on http://regexlib.com. The current dateISO validator allows nonsensical dates like 2008-67-87. {{{ ISO date ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])$ ISO time ^([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?$ ISO offset ^([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?$ ISO date and time ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?)?$ ISO Date, time and offset (the works) ^(\d{4})\D?(0[1-9]|1[0-2])\D?([12]\d|0[1-9]|3[01])(\D?([01]\d|2[0-3])\D?([0-5]\d)\D?([0-5]\d)?\D?(\d{3})?([zZ]|([\+-])([01]\d|2[0-3])\D?([0-5]\d)?)?)?$ }}}

Changed 8 months ago by joern

  • owner set to joern
Note: See TracTickets for help on using tickets.