Configuring a regular expression validator

You can configure a validator customization to ensure that entries for an attribute are in a specific format.

About this task

This task uses a Regular Expression validator to ensure that the values entered by users for an attribute are in a specific format. In the following example, the Product Number attribute requires that values are in the following format: four alphabetic characters, dash, five digits, dash, one of P, Y, or Z.

Procedure

  1. Open the Attribute Customization page:
    1. In the Team Artifacts view of the Work Items perspective, right-click the project area and select Open.
    2. Click the Process Configuration tab.
    3. Expand Project Configuration > Configuration Data > Work Items, and then click Attribute Customization.
  2. Select Validators, then click Add. Enter a name that describes the customization. Select Regular Expression from the Provider drop-down list.
    Screen capture of Add Configuration window with Regular Expression selected in the Provider field.
  3. In the Configuration section, accept the default Decoration Icon of Error. In the Message field, enter the message that is displayed as a tooltip when a user enters a value that does not comply with the specified format. In the Regular Expression field, enter the expression for valid format entries for the attribute. To ensure that your expression is correct, try entering a string in the Try the Regular Expression on sample text field.
    Screen capture of Configuration section for Product Number regular expression.
  4. Click Attributes and Types. Select the work item type, such as Defect or Task. Scroll to the Attributes section. Click Add. Create a custom attribute named Product Number of type Small String. Select Product Number in the Validators field. Click OK.
    Screen capture of Add Custom Attribute window with Product Number selected in Validators field.
  5. Click Editor Presentations. Select the editor presentation to which you want to add a field for the new attribute. Select the tab and then section to which you want to add the field. For example, the Details section on the Overview tab. With the section selected, click Add Presentation to add the field for the new attribute.
  6. Click Save to save your changes to the project area. When users enter values in the Product Number field that are not in the required format, the tooltip message is displayed above the field. However, users can save work items even if they include values that are not in the required format. To prevent users from saving such work items, continue to the next step.
  7. Expand Team Configuration, then click Operation Behavior. Click in the Everyone cell for the Save Work Item action. In the Preconditions section, click Add. Select the Attribute Validation precondition.
    Note: The Attribute Validation preconditions works only with validators that have the Error Decoration Icon.
  8. Click Save to save your changes to the project area.

Results

When users attempt to save work items that have an invalid entry in the Product Number field, the following message is displayed in the Team Advisor view:

Screen capture of Team Advisor view with error message about invalid value of attribute.


video icon Watch videos

CLM playlist
Jazz.net channel
User Education channel

learn icon Learn more

CLM learning circle
Agile learning circle
Learning circles

ask icon Ask questions

Jazz.net forum
developerWorks forums

support icon Get support

Support Portal
Deployment wiki
Support blog