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)[EMAIL PROTECTED]',

        '(?#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

[EMAIL PROTECTED]

DigitalGlobe ®, An Imaging and Information Company

http://www.digitalglobe.com

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

 

_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com


We're hiring! Come hack Perl for Best Practical: 
http://bestpractical.com/about/jobs.html

Reply via email to