Validate text entries in a tracker artifact

You can help users contribute useful information by testing their text entries against rules you configure.

Text fields can be error-prone because they invite free-form input. You can help users provide usable information by automatically rejecting values that don't match the needs of the tracker.

This simplifies things for the user, but for the tracker administrator it can be complicated. So let's look at an example.

Note: If your goal is to require users to enter some value, whatever the value is, don't use text field validation. Select the Required option instead.
  1. Click PROJECT ADMIN from the Project Home menu.
  2. Click Tracker Settings and create a tracker. For this example, let's call it the Bugs tracker. It will be used to record entomological specimens in a collection.
  3. Create a text field and call it Legs. This is for users to record the number of legs each specimen displays.
  4. Select USE FIELD VALIDATION and supply a validation rule that requires the user to enter a number. For example, if a given insect has six legs, you'll want the user to enter the numeral 6, and not a string such as "six" or "several."

    Try this regular expression:

    • \d{1,3}
    This rule requires the user to enter a number with one, two or three digits. Now, a user who means to record a centipede with 100 legs but enters 1000 by mistake will not be able to save the artifact until the error is corrected.
  5. Enter a sample string to test your regular expression. Any part of the sample string that matches your regular expression appears under Match Results. If nothing appears, rework your regular expression until you get a match.
  6. Create another text field and call it Location. This is where users will record the geographical spot where they collected the bug.
  7. Select Use Text Validation and supply a validation rule that requires the user to enter a pair of geographical coordinates. For example, if a given insect was found outside CollabNet's California headquarters, you'll want the user to enter a string like 37.674689,-122.384652, and not something like "Brisbane" or "Out on the lawn."

    Try this regular expression:

    • [-]?[0-9]*[.]{0,1}[0-9]{0,4}
    This rule requires the user to enter two numbers, separated by a comma, in the general format of a pair of mapping coordinates.
    Note: This particular regular expression does not guarantee that the coordinates are valid, just that they look like coordinates.
  8. Save your work. In the tracker whose settings you have been editing, try entering a number greater than 999 in Legs, or a street address in Location The red X next to the field indicates that the text entry is incorrect. A green check indicates that the value meets the requirements.
Notice that any field in which you are validating text entries is identified by Text Entry (with Field Validation) when listed on the TRACKER FIELDS tab.