Home
TR

Validation rules

Collect only values that match your pattern with regex-based accept/reject rules.

Validation rules check every scanned value against a pattern you define before it is added to a list. When you are collecting serial numbers, invoice codes, or fixed-length digit strings, you want to reject most of the noisy text OCR picks up at the door. In QCR Scanner you do this by writing a simple regular expression: if a value matches the rule it is accepted, and if it does not it is silently rejected. That way your list fills up only with the values you actually care about.

What validation does

Without validation, tapping in the camera viewfinder adds whatever OCR read straight into your list. Labels, headings, shadowed edges, and misread characters easily slip into that text. Once you define a validation rule, each candidate value is tested against it first:

  • If the value matches the rule, it is added to the list.
  • If it does not match, it is not added, and your scanning flow continues uninterrupted.
  • In the live preview, only a value that passes validation is shown in green above the viewfinder; readings that fail stay hidden.

The same rules apply to Smart Extract and voice input: values arriving through all of these paths pass through the same validation filter.

How to add a rule

Validation is opened from settings and works per list. The typical flow is:

  1. Open the validation rules section.
  2. Add a new rule.
  3. Give the rule a short name (up to 12 characters). This name only helps you recognize the rule, for example Serial or Invoice.
  4. Enter the regex pattern you want to match.
  5. Enable the rule.

After you save the rule, keep scanning as usual; from then on every value is checked against it before being added.

Tip: If you are not comfortable writing regular expressions, instead of typing the pattern by hand you can use the AI rule generator to turn a plain-language description such as “a digit string between 5 and 8 characters” into a regex automatically.

Multiple rules

You can add more than one validation rule to a list. The important behavior is this: for a value to be accepted, it must match all enabled rules at the same time. Rules do not widen each other with “or” logic; each one acts as a separate condition, and every one of them must pass.

Think of them as filters in series: one rule checks the general shape (digits only, for example), another checks the length, and a third checks a prefix. When you want to loosen a condition temporarily, you do not have to delete the rule, just disable it; disabled rules take no part in the check.

Example patterns

The patterns below cover common collection scenarios. You can add each one as a separate rule:

# Exactly 6 digits
^\d{6}$

# A digit string between 5 and 10 characters
^\d{5,10}$

# A code starting with the "INV-" prefix followed by 4-8 digits
^INV-\d{4,8}$

# A serial of uppercase letters and digits, at least 8 characters
^[A-Z0-9]{8,}$

# A pattern close to a license-plate shape
^\d{2}[A-Z]{1,3}\d{2,4}$

Combining two separate rules is also common. For example, one rule can check that the value is digits only, while a second checks that the length is at least 6:

# Rule 1 (name: DigitsOnly)
^\d+$

# Rule 2 (name: MinLength)
^.{6,}$

With these two rules enabled, only fully numeric values of six or more digits are accepted.

ReDoS protection

Some poorly designed regex patterns can slow down enough on certain inputs to lock up the processor (a situation known as ReDoS). QCR Scanner guards against this risk: excessively long patterns and excessively long inputs are treated as outside the safe limit and rejected. In practice this prevents a faulty or malicious pattern from freezing the app. Avoid very long patterns with nested repeating groups; for most of your needs, the simple patterns above are both fast and safe.

Note: If a rule is not adding the value you expect, the problem is usually a pattern that is too strict. Loosen the pattern temporarily (for example by removing the $ anchor) to see which readings come through, then narrow it step by step.

Validation rules work together with the other collection features in QCR Scanner:

  • Smart Extract splits noisy OCR text into pieces and, using a sliding window, automatically extracts only the parts that pass validation.
  • The AI rule generator turns a plain-language description into a regex for you; you can add the generated pattern as a validation rule.
  • Separator rules keep your list organized by marking some values as section headings rather than data.

QCR Scanner is made by ReviseTouch.

Next steps

  • Smart Extract — pull matching pieces out of noisy text automatically.
  • AI rule generator — generate regex from natural language.
  • Live preview — see the validated value in green in real time.
  • Scanning — viewfinder, capture modes, and tap-to-scan.