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
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.
In this example, the regular expression ^[A-Z]{4}(?:-[0-9]{5})?$ can be broken down into:
Regular Expression | Description |
---|---|
^ | 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:
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.
Here the validation test would fail because you have not included a hyphen separator.
You will also receive an error if the incorrect case is used. E.g. demo-12345.
However, if you enter a value such as DEMO-12345, this would save without any warning or error message.
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.