CHECK Rule

Overview of the CHECK Rule

Use the CHECK rule to instruct the GLASS engine to run each potential match through a specific algorithm as a form of validation to reduce or eliminate false positive matches. A location is only returned as a match if it passes the checksum module that is applied to the GLASS expression(s).

For example, apply the LUHNCHKSUM checksum module to validate the check digit for potential primary account number (PAN) matches.

GLASS Studio CHECK Rule

The generic GLASS syntax for CHECK is:

<search pattern> CHECK '<checksum module>'

See Supported Check Modules for a list of common checksum modules that are built-in and ready to use in your custom data types.

CHECK Example 1

Your organization issues American Express (AMEX) corporate cards for employees who require it.

You develop a custom GLASS data type that searches for AMEX card numbers that are stored in plain text across your organization's storage locations, with the following requirements:

American Express Card Number Requirements

  • All AMEX card numbers are 15 digits long.
  • All AMEX card numbers must start with 34 or 37.
  • AMEX card numbers are stored as 15 straight digits with no separators (e.g. hyphens -, whitespaces  ) and cannot be bounded by digits.
  • The last digit in a valid AMEX card number must pass the Luhn formula for MOD-10 checksum.
MAP 'AMEX_PREFIX' 34, 37
(GROUP 'AMEX_PREFIX' THEN RANGE DIGIT TIMES 13) \
CHECK 'LUHNCHKSUM' BOUND NONDIGIT

Based on the GLASS expression above, the GLASS pattern matching engine will return Line 1 and Line 2 as match locations:

1 CC: 371449635398431
2 John Doe|345678901234564|john.doe@example.com
3 SHA-1 cf23df2207d9937144963539843135e633b65d94
4 CC: 345678901234569

Line 3 and Line 4 will not be returned as match locations.

  • For Line 3, part of the data pattern passed the LUHNCHKSUM checksum but failed the BOUND rule as it is surrounded by digits (9 and 3) on both sides.
  • For Line 4, the data pattern passed the BOUND rule but failed the LUHNCHKSUM checksum due to an invalid check digit (9).

Example 1 in GLASS Studio Visual Builder Mode

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Group label: AMEX_CARD_NUMBER
    • Data type component: LIST (GROUP)
      • Data pattern to search for (+ Create Map):
        • Label : AMEX_PREFIX
        • Entries: 34, 37
    • Data type component: RANGE
      • Data pattern to search for (Use Keyword): DIGIT
      • Repeat Character/Octet (TIMES) option: Checked, 13 times
    • Bound (BOUND) rule (Select a keyword): Non-Digit on the Left and Right.
    • Check (CHECK) algorithm: LUHNCHKSUM

American Express Card Number GLASS Studio configuration

CHECK Example 2

ACME Corporation's regional customer ID is a 12-digit string that starts with a supported 2-character ccTLD (<ccTLD>), followed by a 9-digit serial number (<9-digit serial number>), and a single check digit (<check digit>) that must pass the MOD-10 checksum algorithm adopted for use in Machine Readable Travel Documents (MRTDs).

ACME Corporation Regional Customer ID Number Requirements

To search for the regional customer ID, you write a custom data type as follows:

MAP NOCASE 'ACME_CUST_ID_CCTLD' 'AU', 'IE', 'KR', 'SG', 'UK', 'US'
MAP 'INVALID_SERIAL_NUM' 0

( \
  GROUP 'ACME_CUST_ID_CCTLD' THEN \
  RANGE DIGIT TIMES 9 EXCLUDE 'INVALID_SERIAL_NUM' THEN \
  RANGE DIGIT \
) CHECK 'PASSPORTMOD10' BOUND NONALNUM

The equivalent configuration in GLASS Studio Visual Builder mode is:

  • Group label: ACME_CUST_ID_REGIONAL
    • Data type component: LIST (GROUP)
      • Data pattern to search for (+ Create Map):
        • Label : ACME_CUST_ID_CCTLD
        • Entries: 'AU', 'IE', 'KR', 'SG', 'UK', 'US'
    • Data type component: RANGE
      • Data pattern to search for (Select a keyword): DIGIT
      • Repeat Character/Octet (TIMES) option: Checked, 9 times
      • Exclude (EXCLUDE) rule:
        • MAP Label: INVALID_SERIAL_NUM
        • MAP Entries: 0
    • Data type component: RANGE
      • Data pattern to search for (Use Keyword): DIGIT
    • Bound (BOUND) rule (Select a keyword): Non-Alnum on the Left and Right.
    • Check (CHECK) algorithm: PASSPORTMOD10

ACME Corporation Customer ID CHECK GLASS Studio configuration

Supported Check Modules

The following is a list of all built-in checksum modules that are defined in the GLASS language and can be applied to your custom GLASS expressions.

Checksum Module Description
CHECKACCT Verifies that the data pattern meets the following criteria:
  • No adjacent separators (e.g. ., -,  ) in the data pattern.
  • There are at least two non-separators between each separator.
  • There are no separators at the start or end of the data pattern.
  • There is no more than one letter for every five digits.
  • There are at least six non-separator characters in the data pattern.
CHECKLICENSE Verifies that the data pattern meets the following criteria:
  • There can either be hyphens - or spaces   in the data pattern, but not a combination of both.
  • There can only be asterisks * in the data pattern if the asterisk characters are consecutive.
  • There can only be up to two foward slashes / in the data pattern, with at least two digits between each forward slash character.
  • A single letter or single digit sequence can only appear at the start or end of the data pattern.
  • There must be no more than one occurence of a single letter or single digit sequence in the data pattern.
  • There must be at least one 4-digit sequence (which may be broken by a delimiter) in the data pattern.
  • A sequence of more than three letters can only appear at the start of the data pattern.
IBANMOD97 Verifies that the data pattern passes the International Bank Account Number (IBAN) MOD-97-10 checksum.
ISO8583PAN Verifies that the data pattern passes the ISO 8583 length indicator check and the Luhn formula for MOD-10 checksum.
LUHNCHKSUM Verifies that the data pattern passes the Luhn formula for MOD-10 checksum. This checksum is mainly used for validating the personal account number (PAN) of an identification card (e.g. credit cards).
MAXZEROES_3 Verifies that the data pattern contains at most three ASCII digit zeroes (0).
MAXZEROES_4 Verifies that the data pattern contains at most four ASCII digit zeroes (0).
MAXZEROES_5 Verifies that the data pattern contains at most five ASCII digit zeroes (0).
MINDIGITS_2 Verifies that the data pattern contains at least two ASCII digit (0-9).
MINDIGITS_4 Verifies that the data pattern contains at least four ASCII digit (0-9).
MINDIGITS_6 Verifies that the data pattern contains at least six ASCII digit (0-9).
MINMAXDIGITS_1_4 Verifies that the data pattern contains between 1 to 4 ASCII digits (0-9).
MINMAXDIGITS_4_8 Verifies that the data pattern contains between 4 to 8 ASCII digits (0-9).
MINZEROES_1 Verifies that the data pattern contains at least one ASCII digit zero (0).
PASSPORTMOD10 Verifies that the data pattern passes the MOD-10 checksum algorithm adopted for use in Machine Readable Travel Documents (MRTDs).
SAMECASE Verifies that all letters in the data pattern are either fully uppercase (A-Z) or fully lowercase (a-z) characters.
SEPARATOR Verifies that the separator defined in the preceding RANGE:
  • Is a valid UTF-8 code point, excluding the ASCII whitespace   character (U+0020), and
  • Can only be surrounded by at most one ASCII whitespace character on either side of the separator.

If X represents a valid separator character, the separator in the data pattern must satisfy any of the following conditions:

  • "" - Empty string without any separator.
  • " " - Single whitespace character without any separator.
  • "  " - Two whitespace characters without any separator.
  • "X" - Single separator character.
  • " X" - Single whitespace character before the separator.
  • "" - Single whitespace character after the separator.
  • " X " - Single whitespace character before and after the separator.

UTF8 Verifies that the data pattern is a valid UTF-8 code unit sequence.
VALID_DATE_DDMMYY Verifies that the data pattern given in the short DDMMYY format is a valid date within the 1901-01-01 to 2099-12-31 date range.
VALID_DATE_YYMMDD Verifies that the data pattern given in the short YYMMDD format is a valid date within the 1901-01-01 to 2099-12-31 date range.
VALID_DATE_DMY Verifies that the data pattern given in the Day / Month / Year format is a valid date within the 1901-01-01 to 2099-12-31 date range.
VALID_DATE_MDY Verifies that the data pattern given in the Month / Day / Year format is a valid date within the 1901-01-01 to 2099-12-31 date range.
VALID_DATE_YMD Verifies that the data pattern given in the Year / Month / Day format is a valid date within the 1901-01-01 to 2099-12-31 date range.
VALID_PRESENT_DATE_DMY Same as VALID_DATE_DMY and additionally verifies that the matched date is not greater than the current date. This module can be used to verify dates that cannot be in the future, such as a person's date of birth.
VALID_PRESENT_DATE_MDY Same as VALID_DATE_MDY and additionally verifies that the matched date is not greater than the current date. This module can be used to verify dates that cannot be in the future, such as a person's date of birth.
VALID_PRESENT_DATE_YMD Same as VALID_DATE_YMD and additionally verifies that the matched date is not greater than the current date. This module can be used to verify dates that cannot be in the future, such as a person's date of birth.

Adding CHECK Rules

To add a CHECK rule for a base pattern in GLASS Studio Visual Builder Mode:

  1. Add and define the data pattern for a RANGE, WORD, or LIST component.
  2. In the Add Pattern Rules pane, click on Check.
    GLASS Studio Add CHECK RuleGLASS Studio Add CHECK Rule Pane
  3. Select the checksum algorithm(s) from the list of built-in check modules.
  4. (Optional) Click to remove a selected checksum algorithm from the CHECK rule.
  5. Click Close.

Managing CHECK Rules

To edit a CHECK rule:

  1. Left click anywhere in the component to open the base pattern form.
  2. Click on the Down icon next to the CHECK panel.
  3. Add (check) / remove (uncheck) the selected checksum algorithms.
  4. Click Close.

To remove a CHECK rule:

  1. Left click anywhere in the component to open the base pattern form.
  2. Click on the Trash icon next to the CHECK panel.
    GLASS Studio Delete CHECK Rule
  3. Click Close.