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:
- DateYYYYMMDD - Date in YYYY-MM-DD or YYYY/MM/DD format
- DateMMDDYYYY - Date in MM-DD-YYYY or MM/DD/YYYY format
- DateDDMMYYYY - Date in DD-MM-YYYY or DD/MM/YYYY format
- Float - Floating Point Numbers
- Email - Email address format
- IPAddress - IP Address format
- USZipCode5 - US 5 digit Zip Code
- UZZipCode9 - US 9 digit Zip Code
- USZipCode5or9 - US Zip Code (either 5 digit or 9 digit)
- USTelephone - US Telephone Numbers
- 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])- /.\d\d’,
'(?#DateDDMMYYYY)^(0[1-9]|[12][0-9]|3[01])[-
/.](0[1-9]|1[012])- /.\d\d’,
‘(?#Email)[1][\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@digitalglobe.com mailto:nmetrowsky@digitalglobe.com
DigitalGlobe (r), An Imaging and Information Company
http://www.digitalglobe.com http://www.digitalglobe.com
-
a-zA-Z ↩︎