Skip to content

toml_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:

crates/
crates/a/
crates/a/Cargo.toml
crates/b/
crates/b/Cargo.toml
crates/a/Cargo.toml
[package]
name = "a"
version = "1.2.3"
crates/b/Cargo.toml
[package]
name = "b"
version = "0.4"

With this .alint.yml:

version: 1
rules:
- id: pinned-version
kind: toml_path_matches
paths: "crates/*/Cargo.toml"
path: "$.package.version"
matches: '^\d+\.\d+\.\d+$'
level: error

alint check reports:

Terminal window
--- crates/b/Cargo.toml --------------------------------------------------------
x error pinned-version
value at path "0.4" does not match regex ^\d+\.\d+\.\d+$
Summary (1 violation):
x 1 error
0 passing * 1 failing

Every crate version matches the semver pattern

Section titled “Every crate version matches the semver pattern”

This repository is compliant:

crates/
crates/a/
crates/a/Cargo.toml
crates/b/
crates/b/Cargo.toml
crates/a/Cargo.toml
[package]
name = "a"
version = "1.2.3"
crates/b/Cargo.toml
[package]
name = "b"
version = "0.4.5"

With this .alint.yml:

version: 1
rules:
- id: pinned-version
kind: toml_path_matches
paths: "crates/*/Cargo.toml"
path: "$.package.version"
matches: '^\d+\.\d+\.\d+$'
level: warning

alint check reports:

Terminal window
v All 1 rule(s) passed.