validate

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package validate exposes syntax validation for external consumers.

This is the public API for mache's AST validation. Since mache-73b885 it is backed by the pinned leyline daemon's `validate` op (ley-line-open >= v0.8.0) instead of in-process tree-sitter. As of v0.8.0 the daemon validates EVERY mache registry language except CUE (no tree-sitter-0.26 grammar exists); HCL/Terraform validates in-process via hclsyntax (a fast, offline path — the daemon covers it too). Only .cue and unrecognized extensions pass through with no error. A leyline daemon is acquired lazily on first use (see internal/leyline ValidateContent for the latency profile); daemon-acquisition failures surface as ordinary errors, never as false "valid" results.

Usage:

err := validate.File("path/to/file.go")
errors := validate.FileErrors("path/to/file.go")
err := validate.Content([]byte("package main"), "main.go")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Content

func Content(content []byte, filePath string) error

Content validates content for the language inferred from filePath's extension. Returns nil if the AST is clean or the extension is not validated (pass-through).

func File

func File(filePath string) error

File reads a file from disk and validates its AST.

func SupportedExtension

func SupportedExtension(filePath string) bool

SupportedExtension returns true if the file extension is validated by the leyline daemon's validate op.

Types

type ValidationError

type ValidationError = writeback.ValidationError

ValidationError contains structured information about a syntax error.

func ContentErrors

func ContentErrors(content []byte, filePath string) []ValidationError

ContentErrors returns all AST error locations for diagnostic reporting. Returns nil if no errors or unknown language.

func FileErrors

func FileErrors(filePath string) []ValidationError

FileErrors reads a file from disk and returns all AST error locations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL