xml_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.
Options
Section titled “Options”| Option | Type | Required | Default | Description |
|---|---|---|---|---|
if_present | boolean | false | When true, a query returning zero matches is silently OK - only real matches that fail the op produce violations. | |
matches | string | yes | Rust-regex pattern to match against the value at path. | |
path | string | yes | JSONPath 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.
Example
Section titled “Example”A Maven dependency whose version is not a concrete release
Section titled “A Maven dependency whose version is not a concrete release”The rule fires on this repository:
pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <dependencies> <dependency><artifactId>guava</artifactId><version>33.0.0-jre</version></dependency> <dependency><artifactId>internal</artifactId><version>${revision}</version></dependency> </dependencies></project>With this .alint.yml:
version: 1rules: - id: pom-deps-pinned kind: xml_path_matches paths: "pom.xml" path: "$.project.dependencies.dependency[*].version" matches: '^\d' level: erroralint check reports:
--- pom.xml -------------------------------------------------------------------- x error pom-deps-pinned value at path "${revision}" does not match regex ^\d
Summary (1 violation): x 1 error 0 passing * 1 failingEvery Maven dependency declares a concrete version
Section titled “Every Maven dependency declares a concrete version”This repository is compliant:
pom.xml<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <dependencies> <dependency><groupId>com.google.guava</groupId><artifactId>guava</artifactId><version>33.0.0-jre</version></dependency> <dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.13.2</version></dependency> </dependencies></project>With this .alint.yml:
version: 1rules: - id: pom-deps-versioned kind: xml_path_matches paths: "pom.xml" path: "$.project.dependencies.dependency[*].version" matches: '^\d' level: erroralint check reports:
v All 1 rule(s) passed.