Field Data Format Validation using Regular Expressions

Regular Expression (or RegEx) are patterns that can be used to define valid input text. RegEx's are commonly used by search engines and for validating data input in to text boxes. Those patterns consist of one or more character literals, operators, or constructs. They are very powerful but they are also quite complicated if you are not a software developer.

They Directory Update and Directory Manager have a feature we call format validation that allows you to control the content and the format of that content with a great degree of precision. This is done by defining a field format validation and a regular expression (aka RegEx) that defines the format of data placed in to that field. The most common use of this feature is to define formats for telephone numbers, but the field format feature can be used with almost any field (except country, manager, secretary, and assistant.)

Ithicos Solutions does not provide customized regular expressions. We recommend you use sites such as

There are two elements to using in Directory Update and Directory Manager that are used to define the validation format and then assign it to a text field. The first is the section of the DirectorySettings.XML file which is used to your validation formats. The second is the validationFormat option that you assign to a specific attribute tag in the DirectorySettings.XML

Each validation format consists of the format name, some example text for the end user, and the actual RegEx that is used to validate the input in to the text field. Here is the default validations section from the DirectorySettings.XML file which has some examples.

  <validation format="US-Phone" formatExample="Example: (808) 123-4567 or 808-123-4567 x4321" regularExpression="((\(\d{3}\) ?)|(\d{3}-))\d{3}-\d{4}(( x)\d{1,5}| )?" />
  <validation format="UK-Phone" formatExample="Example: +44 (0) 123 456 7890 or +44 (0) 1234 567890" regularExpression="(\+44 )(\(\d\) )((\d{3} )(\d{3} )\d{4}|(\d{4} )\d{6})(( x)\d{1,5}| )?" />
  <validation format="Australia-Phone" formatExample="Example: +61 2 1234 5678 or +61 (0)3 1234 5678" regularExpression="(\+61 )((\(\d\))?\d )(\d{4} )\d{4}(( x)\d{1,5}| )?" />
  <validation format="Norway-Phone" formatExample="Example: +47 12 34 56 78" regularExpression="^(\+47 )(\d{2} )(\d{2} )(\d{2} )\d{2}(\s)?$" />
  <validation format="Ireland-Phone" formatExample="Example: (+353) 1 1234567 or +353 1 1234567" regularExpression="(\(\+353\)|\+353)\s\d{1}\s\d{7}(\s)?$" />
  <validation format="US-ZipCode" formatExample="Example: 96816 or 96816-1234" regularExpression="\d{5}(-\d{4})?(\s)?$" />

One you define a validation format that you want to use, you then use the validationFormat tag to assign it to an attribute. In this example, the format name "US-Phone" is being assigned to the office phone number attribute

 <officePhone label="Office Phone" type="text" visible="yes" editable="yes" validationFormat="US-Phone"></officePhone>

Regular Expression Resources

So, yes, RegEx's are complicated. That is the bad news. But, the good news is that for most things that a Systems Administrator might want to do, someone has already created a RegEx and published it on the Internet!

Last Review: 15 Dec 2016