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

Nick Metrowsky nmetrowsky at digitalglobe.com
Fri Jun 23 15:38:27 EDT 2006


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.

 

I hope you find this information useful. Also, if folks have additional
regular expressions they should contribute them to this forum so they
can be shared with everybody.

 

Take care!

 

Nick

 

The following module contains the Custom Field Validation definitions
for RT 3.6.0:

 

/opt/rt3/share/html/Admin/CustomFields/Modify.html

 

The following code begins at line 82; I removed the regexp for "Years"
and added new code beginning at line 89:

 

<& /Widgets/ComboBox,

    Name    => 'Pattern',

    Default => $CustomFieldObj->Pattern,

    Size    => 50,

    Values  => [

        '(?#Mandatory).',

        '(?#Digits)^[\d.]+$',

 
'(?#Float)^(\+|-)?([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?',

        '(?#DateYYYYMMDD)^(19|20)\d\d([-
/.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])$',

        '(?#DateMMDDYYYY)^(0[1-9]|1[012])[-
/.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d',

        '(?#DateDDMMYYYY)^(0[1-9]|[12][0-9]|3[01])[-
/.](0[1-9]|1[012])[- /.](19|20)\d\d',

 
'(?#Email)^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[
a-zA-Z][a-zA-Z\.]*[a-zA-Z]$',

 
'(?#IPAddress)^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}
(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$',

        '(?#USZipCode5)^\d{5}$',

        '(?#USZipCode9)^\d{5}-\d{4}$',

        '(?#USZipCode5or9)^\d{5}(-?\d{4})?$',

 
'(?#USTelephone)^1?\s*-?\s*(\d{3}|\(\s*\d{3}\s*\))\s*-?\s*\d{3}\s*-?\s*\
d{4}$',

        '(?#RowRackHeight)^\d{2}-\d{2}-\d{2}$',

        '',

    ],

&>

 

------------------------------------------------------------------------
---------

Nick Metrowsky

Consulting System Administrator

303-684-4785 Office

303-684-4100 Fax

nmetrowsky at digitalglobe.com <mailto:nmetrowsky at digitalglobe.com> 

DigitalGlobe (r), An Imaging and Information Company

http://www.digitalglobe.com <http://www.digitalglobe.com> 

------------------------------------------------------------------------
---------

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20060623/7d59fcaf/attachment.htm>


More information about the rt-users mailing list