[rt-users] Regular Expressions for Custom Field Validation in RT 3.6.0

Todd Chapman todd at chaka.net
Fri Jun 23 17:56:13 EDT 2006


On Fri, Jun 23, 2006 at 01:38:27PM -0600, Nick Metrowsky wrote:
> Hi Everyone,
> 
>  
> 
> Once I was told where Custom Field Validation is maintained in RT 3.6.0,
> I thought I make this small contribution to RT 3.6.0. The following code
> snippet contains several useful regexp validations. Two of these are
> provided with RT 3.6.0 (Mandatory, Digits), the new additions are as
> follows:
> 
>  
> 
> 1.	DateYYYYMMDD - Date in YYYY-MM-DD or YYYY/MM/DD format
> 2.	DateMMDDYYYY - Date in MM-DD-YYYY or MM/DD/YYYY format
> 3.	DateDDMMYYYY - Date in DD-MM-YYYY or DD/MM/YYYY format
> 4.	Float - Floating Point Numbers
> 5.	Email - Email address format
> 6.	IPAddress - IP Address format
> 7.	USZipCode5 - US 5 digit Zip Code
> 8.	UZZipCode9 - US 9 digit Zip Code
> 9.	USZipCode5or9 - US Zip Code (either 5 digit or 9 digit)
> 10.	USTelephone - US Telephone Numbers
> 11.	RowRackHeight - Something used by us locally for locating
> equipment in out data center; Row #, Rack #, and Unit Height # in Rack.
> 
>  

Nick,

I submitted a patch to Jesse that implements a callback
so that new validations can be easily added. Hopefully the
patch will make it into 3.6.1.

Also, for every validation it would be useful to have
another validation that makes it possible to insert
no data.

For example:

(?#Date)^\d\d\d\d-\d\d-\d\d$
(?#Optional Date)^(\d\d\d\d-\d\d-\d\d)?$

The first requires a date. The second allows a blank
CF, but a date is entered it has to match the format.

-Todd




More information about the rt-users mailing list