Data validation for property types
Validation rules check that supplied data is in a valid format, such as two letters followed by three digits. These rules are defined through the use of regular expressions, a simple and powerful language.
Validation rules can be used when defining reference data
types. The Code validation rule field validates
the Code field that is entered for the values in a set. For example,
if your reference data set is for states or provinces, and you want
the code to be a two-letter abbreviation that uses only capital letters,
the code validation rule is [A-Z]{2}. You can also
use validation rules in the Validation rule field
when defining the settings for a string data type of a custom property.
A rule is considered matched if the text that is being checked fits the constraints imposed by the rule you defined.
More information about data validation rules can be found in Validation rules. Detailed tutorials on regular expressions are outside the scope of this document.
Example 1 – code format
[A-Za-z]{2}[\d]{3}- [
- The beginning of a rule for matching a single character.
- A-Za-z
- Match any characters in the range of A-z (uppercase and lowercase letters).
- ]
- The end of the rule for matching a character.
- {2}
- The previous section must match two consecutive characters.
- [\d]
- A short way of saying [0-9].
- {3}
- The previous section must match three consecutive characters.
Example 2 – alphanumeric code
[A-Za-z0-9]+- [A-Za-z0-9]+
- Match any alphanumeric character.
- +
- Match the previous section at least once, with no upper limit.
Example 3 – part number
[\d]{6,8}(-[\d]{5})?- [\d]{6,8}
- Match six to eight digits in a row.
- (
- Begin a new section.
- -
- Literally match the - character.
- [\d]{5}
- Match five digits in a row.
- )
- End the section began by the previous (.
- ?
- The previous section does not have to be matched, but cannot match more than once. (The section is optional.)
Example 4 – email address
Here is a simple example of an email address validation.
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z]{2,4}\b- \b
- The beginning of a word boundary.
- [A-Za-z0-9._%+-]
- Match any combination of uppercase and lowercase letters, digits, and the period, underscore, percent sign, plus sign, or minus sign characters.
- +@
- The next character must be an at sign (@).
- [A-Za-z0-9.-]
- Match any combination of uppercase and lowercase letters, digits, and the period or minus sign characters.
- +\.
- Literally match the period character.
- [A-Za-z]{2,4}
- The next 2 - 4 characters must be letters.
- \b
- The end of a word boundary.