The pattern field in rules supports three reference prefixes that resolve values dynamically at evaluation time.
Reference a value defined in the [vars] section of align.toml.
[vars]
node_version = ">=18"
["services/*".correct-node-version]
check = "field_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "var:node_version"The pattern resolves to ">=18" before the check runs.
If the variable is not defined, the check fails with an error message.
Reference a shell environment variable directly.
["services/*".correct-node-version]
check = "field_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "env:NODE_VERSION"If the environment variable is not set, the check fails with an error message.
env: can also be used inside [vars] values, allowing indirection through config variables:
[vars]
node_version = "env:NODE_VERSION"
["services/*".correct-node-version]
check = "field_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "var:node_version"When var:node_version is resolved, it finds "env:NODE_VERSION" and automatically resolves the environment variable.
Read the contents of a file (relative to the repository root) and use it as the pattern. Leading and trailing whitespace is trimmed.
["services/*".node-version-matches-file]
check = "field_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "file:.node-version"If .node-version contains 18\n, the pattern resolves to "18".
If the referenced file cannot be opened or read, the check fails with an error message.
Any pattern value without a recognized prefix is used as-is:
pattern = "extends" # literal substring match
pattern = "console.log" # literal substring matchReferences are resolved in the pattern field of these check types:
file_contains/file_not_containsfield_contains/field_not_contains