Skip to content

Skip criteria with unusable JSONPath regex, apply matches to strings only (dpp-criteria 4b17bb8) - #6

Merged
fabianekc merged 1 commit into
mainfrom
jsonpath-regex-unusable-matches-strings
Sep 28, 2026
Merged

fabianekc merged 1 commit into
mainfrom
jsonpath-regex-unusable-matches-strings

Conversation

@fabianekc

Copy link
Copy Markdown
Member

Adapts dpplint to dpp-criteria 4b17bb8 (PR #6), sections "Regular expressions" and "Results" in CRITERIA-FORMAT.md.

Changes

  • Patterns in match() and search() are checked before the JSONPath is evaluated. An invalid I-Regexp, or one with ^ or $ outside a character class, makes the criterion skipped with the reason instead of letting the function return false.
    • IRegexp now reports these as Invalid or Anchored. ^ and $ are no longer translated into anchors.
    • ^ and $ inside a character class stay allowed ([^a], [a^], [$]).
  • matches holds only for JSON strings. Numbers, booleans, null, arrays and objects never satisfy it and are no longer converted to text. Header values are always strings, so header assertions are unchanged.

Tests

  • 163 runs, 557 assertions, 0 failures, 0 errors, 0 skips in the image built with ./build.sh (dpp-criteria 4b17bb8).
  • Unusable patterns: ^ab.*, .*bc$, ^[Bb]atter, 59040|PCDS$, (^a) and a\^b give "contains … outside a character class"; [^a], [a^], [$] and [\^] are accepted. An invalid I-Regexp gives the reason even with exists: false.
  • In the linter: applies_if with search(@, '^[Bb]atter') is skipped with the reason and does not enter "N of M".
  • matches: matches the string "1", but not 1, true, null, an array, an object or 59040.0.

Reference passport

https://dpp.oydapp.eu/01/09520123456788/21/000001:

  • Overall: 13 of 13 automated checks passed, 0 failed, 1 warning (DPP-ID-016), 9 skipped.
  • Not applicable: DPP-BAT-002, DPP-PCDS-008 and DPP-ID-010 are skipped because their condition is not met; their patterns are usable.

Results are from automated checks only and establish no presumption of conformity.

Decisions

  • An escaped \^ outside a character class also counts as unusable, following the wording "must not contain ^ … outside a character class". This errs towards skipped, never failed.

Open questions for dpp-criteria

  1. Does the rule also cover an escaped \^ outside a character class, or only an unescaped ^?
  2. Should CI also check patterns in match()/search() (valid I-Regexp, no ^/$ outside a character class), so that an unusable pattern is caught in the pull request rather than by the runner?

@fabianekc
fabianekc merged commit 99dc54f into main Sep 28, 2026
2 checks passed
@fabianekc
fabianekc deleted the jsonpath-regex-unusable-matches-strings branch September 28, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant