Skip to content

dotenv_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.

A .env DATABASE_URL pointing at the wrong engine

Section titled “A .env DATABASE_URL pointing at the wrong engine”

The rule fires on this repository:

.env
.env
DATABASE_URL=mysql://localhost/app

With this .alint.yml:

version: 1
rules:
- id: postgres-only
kind: dotenv_path_matches
paths: ".env"
path: "$.DATABASE_URL"
matches: "^postgres://"
level: error

alint check reports:

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

This repository is compliant:

.env
.env
DATABASE_URL=postgres://localhost/app

With this .alint.yml:

version: 1
rules:
- id: postgres-only
kind: dotenv_path_matches
paths: ".env"
path: "$.DATABASE_URL"
matches: "^postgres://"
level: error

alint check reports:

Terminal window
v All 1 rule(s) passed.