Specifying Custom Number Format in Free Text Categories

In a project, you may wish to enter a supporting reference number for an item of data. For example, an Equipment Number. This number might require a given format.

Where:

Project Code –  4 alpha characters
Equipment Code – 5 numerical characters

Supporting Reference Number
Supporting Reference Number for a Project

You can achieve this by creating a user-defined category with no category values defined and include a Category Verification Test using a Regular Expression.

Example Category Verification Test for Reference Number category
Example Category Verification Test

In this example, the regular expression ^[A-Z]{4}(?:-[0-9]{5})?$ can be broken down into:

Regular ExpressionDescription
^The beginning of the string
[A-Z]{4}The project code must be 4 alpha characters long in uppercase
?:-A hyphen separator
[0-9]{5}The equipment code must be 5 numeric characters
$The end of the string

Applying Category to the Item

Once you have defined the category, you can assign this to an item type:

Assigning Categories
Assign Category to Item Type

Creating/Editing an Item

If you now create or modify an item of data, Cradle will present you with an error message on saving if the category value does not match what you have specified in the Category Verification Test.

Reference Number
Reference Number in Categories
Invalid Category Value dialog
Invalid Category Value dialog

Here the validation test would fail because you have not included a hyphen separator.

Validation Test result
Validation Test result

You will also receive an error if the incorrect case is used. E.g. demo-12345.

Invalid Validation Test
Invalid Validation Test

However, if you enter a value such as DEMO-12345, this would save without any warning or error message.

Example saved category
Example saved category

Summary

Regular expressions can be used in many areas of the tool. Using this functionality to enforce an input in free text categories can be a very useful feature.

For further information about regular expressions (regexes) please refer to the page https://www.threesl.com/cradle/help/7.7/#general/regularexpressions.htm.