Skip to main content

Configuration File

The validator supports a .cfv.toml configuration file for project-level defaults. Instead of passing flags on every invocation, define your settings once and commit them to the repository.

Discovery​

On startup, the validator looks for .cfv.toml in the current directory and walks up parent directories until it finds one or reaches the filesystem root.

To specify a file explicitly:

validator --config=path/to/.cfv.toml .

To disable auto-discovery:

validator --no-config .

Precedence​

Most CLI flags can also be set through environment variables prefixed with CFV_. When multiple sources set the same option, the validator resolves them in this order (highest priority first):

  1. CLI flags
  2. .cfv.toml configuration file
  3. Environment variables (CFV_*)
  4. Built-in defaults

Example​

exclude-dirs = ["node_modules", ".git", "vendor", "dist"]
exclude-file-types = ["csv"]
ignore-files = [".dockerignore", ".prettierignore"]
depth = 3
quiet = false
gitignore = true
schemastore = true
require-schema = false
reporter = ["standard"]
groupby = ["filetype", "pass-fail"]

[schema-map]
"**/package.json" = "schemas/package.schema.json"
"**/config.xml" = "schemas/config.xsd"

[type-map]
"**/inventory" = "ini"
"**/*.cfg" = "json"

[validators.csv]
delimiter = ";"
comment = "#"

[validators.json]
forbid-duplicate-keys = true

All configuration keys​

KeyTypeDefaultDescription
exclude-dirsarray of strings[]Subdirectories to skip during traversal
exclude-file-typesarray of strings[]File types to ignore
ignore-filesarray of strings[]Gitignore-style pattern files to apply during file discovery
file-typesarray of stringsallOnly validate these file types
depthinteger (≥ 0)unlimitedMaximum recursion depth
reporterarray of strings["standard"]Output formats: standard, json, junit, sarif, github
groupbyarray of strings[]Group output by: filetype, directory, pass-fail, error-type
quietbooleanfalseSuppress stdout output
require-schemabooleanfalseFail files that support schemas but don't declare one
no-schemabooleanfalseDisable all schema validation
schemastorebooleanfalseEnable SchemaStore catalog lookup
schemastore-pathstring—Path to local SchemaStore clone (implies schemastore)
globbingbooleanfalseTreat positional arguments as glob patterns
gitignorebooleanfalseSkip files matched by .gitignore patterns
schema-maptable—Map glob patterns to schema files
type-maptable—Map glob patterns to file types
validatorstable—Per-validator options (see below)

Schema and type maps​

Both schema-map and type-map are TOML tables where keys are glob patterns and values are paths (for schemas) or type names (for type-map).

[schema-map]
"**/package.json" = "schemas/package.schema.json"
"**/pom.xml" = "schemas/maven.xsd"

[type-map]
"**/inventory" = "ini"
"**/.env.*" = "env"

Glob patterns follow the same syntax as --schema-map and --type-map CLI flags. See Glob Patterns for pattern syntax details.

Validator options​

Some validators accept format-specific options that control how files are parsed. These are set under [validators.<type>] tables.

CSV​

KeyTypeDefaultDescription
delimiterstring","Field delimiter character. Use "\t" for tab-separated.
commentstring—Lines starting with this character are skipped.
lazy-quotesbooleanfalseAllow bare quotes in unquoted fields.
[validators.csv]
delimiter = "\t"
comment = "#"
lazy-quotes = true

JSON​

KeyTypeDefaultDescription
forbid-duplicate-keysbooleanfalseReport duplicate keys in objects as errors.
[validators.json]
forbid-duplicate-keys = true

INI​

KeyTypeDefaultDescription
forbid-duplicate-keysbooleanfalseReport duplicate keys within the same section as errors.
[validators.ini]
forbid-duplicate-keys = true
note

YAML duplicate keys are always rejected by the YAML parser regardless of configuration.

Validation of the config file itself​

The .cfv.toml file is validated against a built-in schema on load. Typos in key names and invalid value types are reported immediately as errors (exit code 2).

$ validator .
Error: .cfv.toml: unknown key "exlude-dirs" (did you mean "exclude-dirs"?)