Skip to content

ini_path_matches

Same shape as the *_equals variants, but the asserted value is a regex matched against string values. Non-string matches produce a clear “value is not a string” violation.

OptionTypeRequiredDefaultDescription
if_presentbooleanfalseWhen true, a query returning zero matches is silently OK - only real matches that fail the op produce violations.
matchesstringyesRust-regex pattern to match against the value at path.
pathstringyesJSONPath expression rooted at $.

Plus the common paths, level, id, and when fields. This table is generated from the JSON Schema; option types and defaults are authoritative.

The rule fires on this repository:

config.ini
config.ini
[database]
url = jdbc:mysql://localhost/app

With this .alint.yml:

version: 1
rules:
- id: postgres-only
kind: ini_path_matches
paths: "config.ini"
path: "$['database']['url']"
matches: "^jdbc:postgresql:"
level: error

alint check reports:

Terminal window
--- config.ini -----------------------------------------------------------------
x error postgres-only
value at path "jdbc:mysql://localhost/app" does not match regex
^jdbc:postgresql:
Summary (1 violation):
x 1 error
0 passing * 1 failing

This repository is compliant:

tox.ini
tox.ini
[testenv]
deps =
pytest
coverage
commands = pytest

With this .alint.yml:

version: 1
rules:
- id: deps-includes-pytest
kind: ini_path_matches
paths: "tox.ini"
path: "$['testenv']['deps']"
matches: "pytest"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.

This repository is compliant:

config.ini
config.ini
[database]
url = jdbc:postgresql://localhost/app

With this .alint.yml:

version: 1
rules:
- id: postgres-only
kind: ini_path_matches
paths: "config.ini"
path: "$['database']['url']"
matches: "^jdbc:postgresql:"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.