Skip to content

Overview

Hand-written YAML data models are easy to get subtly wrong — a typo, a missing field, or a value that violates an organization’s naming or design standards often isn’t caught until a terraform plan fails, or worse, until a non-compliant change reaches production. nac-validate catches both classes of error up front: syntax and schema mistakes, and semantic/business-rule violations against custom validation rules — before the data model is ever consumed by downstream tooling.

$ nac-validate --help
Usage: nac-validate [OPTIONS] [PATHS]...
A CLI tool to perform syntactic and semantic validation of YAML files.
Arguments:
[PATHS]... List of paths pointing to YAML files or directories
Options:
-v, --verbosity [DEBUG|INFO|WARNING|ERROR|CRITICAL]
Verbosity level [env: NAC_VALIDATE_VERBOSITY] [default: WARNING]
-s, --schema FILE Path to schema file [env: NAC_VALIDATE_SCHEMA] [default: .schema.yaml]
-r, --rules DIRECTORY Path(s) to directories with semantic validation rules (repeatable)
[env: NAC_VALIDATE_RULES]
-o, --output FILE Write merged content from YAML files to a new YAML file
[env: NAC_VALIDATE_OUTPUT]
--non-strict Accept unexpected elements in YAML files
[env: NAC_VALIDATE_NON_STRICT]
-f, --format [text|json]
Output format for validation results
[env: NAC_VALIDATE_FORMAT] [default: text]
--no-color Disable colored output [env: NO_COLOR]
--compact Use compact output format without rule context details
[env: NAC_VALIDATE_COMPACT]
--version Display version number
--list-rules List all available validation rules and exit
--help Show this message and exit

Syntactic validation is done by basic YAML syntax validation (e.g., indentation) and by providing a Yamale schema and validating all YAML files against that schema. Semantic validation is done by providing a set of rules (implemented in Python) which are then validated against the YAML data — see Usage for how to write rules.