validate

Function validate 

Source
pub fn validate(file: &str, strict: bool) -> Result<(), CliError>
Expand description

Validate a HEDL file for syntax and structural correctness.

Parses a HEDL file and reports whether it is syntactically valid. In strict mode, all entity references must resolve to defined entities.

§Arguments

  • file - Path to the HEDL file to validate
  • strict - If true, enables strict reference validation (all references must resolve)

§Returns

Returns Ok(()) if the file is valid, Err with a descriptive error message otherwise.

§Errors

Returns Err if:

  • The file cannot be read
  • The file contains syntax errors
  • In strict mode, if any entity references cannot be resolved

§Examples

use hedl_cli::commands::validate;

// Validate a well-formed HEDL file
validate("valid.hedl", false)?;

// Strict validation requires all references to resolve
validate("references.hedl", true)?;

// Invalid syntax will fail
let result = validate("invalid.hedl", false);
assert!(result.is_err());

§Output

Prints a summary to stdout including:

  • File validation status (✓ or ✗)
  • HEDL version
  • Count of structs, aliases, and nests
  • Strict mode indicator if enabled