Validation Pattern Matching – the Scan Mask

What options are available for Pattern Validation and Duplicate Checking?

When creating a ‘Validate Scans’ service type, you have two options even without having a complete database to validate against.

  1. First, you can check the ‘Apply a Validation Pattern’ box. You can find the instructions below. The benefits of this option include a) the ability to easily add scanned values to the database if they are not already there; b) forcing an invalid response if there’s a match – for example, to indicate if an item is discontinued.
  2. Second, you can create a standard validation service (i.e. don’t check the ‘Apply a Validation Pattern’ box) but when creating your service, use the powerful Alter Scan Value feature.

What can I do with Validation Patterns?

You can catch invalid or duplicate IDs without a complete database residing on our servers – or even without a database at all.

Use-cases include:

  1. Tickets can now be sold immediately prior to an event without needing to upload their ticket IDs to codeREADr. In fact, no ticket IDs need to be uploaded at all to catch duplicates.
  2. Service providers don’t have to upload databases to our servers – whether for privacy concerns (e.g. student or patient IDs) or because the database is too large (e.g. coupon IDs).

Once scanned, the actual scanned ID is stored either online or on the device to enable checking for duplicates and to provide reporting.

What is Pattern Matching?

Validation Pattern matching is an advanced concept in which a user can specify how the app reacts to scans that match a “pattern”. The format of a pattern relies on three things:

  • Length: Barcodes must have the length of the pattern to match.
  • Required Characters: Barcodes must match positions in which there are letters, numbers, or symbols in the pattern.
  • Wildcards: Barcodes can have any character in the position where the symbol ? is placed.

If the pattern entered is F767-??????, any barcode that starts with the characters ‘F767-‘ and ends with any six characters will be returned as valid.

Here are some entries that would and would not match the pattern F767-??????:

F 67 7-abc123does not match: the 7 and 6 are in the wrong position.
F767-abc123 4does not match: too many characters
f 767-abc123does not match: one of the required characters is in the incorrect case
Code Pattern

How to Setup a Validation Pattern Matching Service:

  1. Create a validation service, or edit one of your existing services.
  2. Click “Apply a Validation Pattern”. Then, a new section will appear.
  3. Using normal characters and the ? symbol, define a pattern. ( See Examples Above )
  4. Enter a response to show the app user when the pattern is matched.
  5. [OPTIONAL] Checking the box ‘Add scanned value and response to the database when a match is made’ will add the scanned barcode, the pattern’s response, and its validity to the service’s database.

IMPORTANT: If you want to check for Duplicate scans you need to check this box. However, the scanned value cannot be greater than 100 characters for this setting unless you use the Alter Scan Value feature (Example D) to limit the number of characters captured to 100 or less.

  1. Press ‘Save and Continue’ to save your changes and continue creating/updating your service.

Combining Scan Mask with Databases.

You can use Scan Mask with or without a validation database. If you upload a database to our servers, this service type will first check that database to see if the barcode value is in the database. Then, if it is, it validates against that database. However, if it isn’t, it validates against the pattern.

No Pattern? No Problem.

If your IDs don’t have a known pattern other than the number of characters in the ID, then you can use the ? wildcard for every position to save the barcode value to the associated database. If you don’t have a known pattern and not all barcode values are the same length, leave the Code Pattern field empty. Then, anything you scan will be added to the database.

Why would you use Scan Mask’s pattern validation without a pattern or even without an original validation database? Because it enables you to add barcode values to a database when you check the box ‘Add scanned value and response to the database when a match is made’. Thus, you can catch duplicate scans for both online and on-device database services.

Stopping Duplicate Scans.

On the first step, when creating or editing your Validate Scans service, you simply need to select the option to make duplicate scans invalid.

What would a typical set-up look like for validating with a partial or empty database?

Validate with partial database

Why ‘force’ an invalid response?

If you check the box ‘Force an invalid response when a scan match is made’, you can alert the app user when certain barcode values need special attention. For example, you could alert them when they scan expired tickets or discontinued items.

Need a more sophisticated validation pattern?  Use regex!

You can use the Alter Scan Value option with regex. Also, for some configurations, you can do that here too. Simply check the box ‘Use Regular Expression’ and enter your script in the form field. To limit the number of characters captured you need to use the Alter Scan Value feature.

Example A – Allow any number of alpha or numeric characters after the prefix ‘xx’ to be valid.


Example  B – Allow only 5 digits to be valid.


Example C – Allow only 4 or 5 digits after a prefix ‘xx’ to be valid.


Example D – Allow only 8, 9, or 10, digits after a prefix ‘xx’ to be valid.


Example E – Allow only 5 digits after ‘xx’ or ‘XX’ to be valid.


Example F – Allow only 8, 10, or 12 digits after a prefix ‘xx’ to be valid.


Example G – Allow only MX or WX prefix with any number of alpha or numeric characters to be valid.


Note: For Android OS devices in some cases you may need to escape the { } (curly braces) if used as a literal character. So, for example, you would use \{ and \} in the regex.

Need help writing your regex? Contact support.

Does the pattern validation service type work with the Alter Scan Value and Alter Scan Response features?

Yes, it does.

in Services