[rt-users] Custom field format validation without being mandatory

Kevin Falcone falcone at bestpractical.com
Wed Jul 27 17:50:12 EDT 2011


On Wed, Jul 27, 2011 at 11:59:44AM -0700, Edward Frye wrote:
>      How can I setup a custom field validation and have if so that it can be blank, OR match my
>      regular expression
>      Currently I have: (?#YYYY-MM-DD HH:mm:ss)^[12]\d{3}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$
>      Really what I guess what I think I'm looking for is /(^[12]\d{3}-\d{2}-\d{2}
>      \d{2}:\d{2}:\d{2}$|^$)/

perldoc perlre will tell you more than you ever wanted to know, but
something like:
/^(?:foo|)$/ or /^foo$|^$/
is what you want to emulate.

Remember that the (?#YYYY-MM...) part needs to be self contained since
it isn't an active part of the regex.

-kevin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110727/b9a22514/attachment.sig>


More information about the rt-users mailing list