Validates prompt frontmatter and variable consistency.
Summary
Functions
Validates prompt frontmatter against the expected schema, checking required fields, variable declarations, and optionally variable consistency between declarations and template usage.
Validates a %Prompt{} struct by attempting a strict-mode render with the
provided variables, verifying that the template can be fully rendered.
Types
Functions
@spec validate_prompt(map(), String.t(), String.t() | nil, keyword()) :: {:ok, :prompt} | {:error, error_list()}
Validates prompt frontmatter against the expected schema, checking required fields, variable declarations, and optionally variable consistency between declarations and template usage.
Parameters
frontmatter— Parsed YAML frontmatter as a map.body— The template body string.path— Optional file path for error context.opts— Keyword options::schema— Validation schema (:devman,:human,:flex).:validate_variables— Whether to check declaration/usage consistency.
Returns
{:ok, :prompt} if valid, or {:error, [%ValidationError{}]} with all errors.
@spec validate_prompt_struct(CommBus.Template.Prompt.t(), map(), keyword()) :: {:ok, CommBus.Template.ValidationResult.t()} | {:error, CommBus.Template.RenderError.t()}
Validates a %Prompt{} struct by attempting a strict-mode render with the
provided variables, verifying that the template can be fully rendered.
Parameters
prompt— A%CommBus.Template.Prompt{}struct.variables— A map of variable bindings to test with.opts— Keyword options forwarded to the template engine.
Returns
{:ok, %ValidationResult{}} with required variables and partials, or
{:error, %RenderError{}} if the render fails.