validator

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package validator wraps boxer's nanopass.Parse (ClickHouse Grammar1) to provide sub-millisecond in-process syntax validation for the time range picker's expression fields. The picker calls Validate on every keystroke; on parse error it surfaces a red underline in the field. Evaluation against clickhouse-local is deferred until Apply (see the evaluator sub-package).

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMCompiles,
	WASMJS:           packageprops.WASMCompiles,
	WASMFreestanding: packageprops.WASMCompiles,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `boxer code analysis golang wasmsurvey props generate`; curate by hand. The same group's `props verify` reconciles it.

Functions

func Validate

func Validate(fragment string) (err error)

Validate parses the given ClickHouse SQL fragment using boxer's Grammar1 parser. Returns nil on parse success; returns an error describing the first syntax error otherwise.

The fragment is wrapped in a SELECT before parsing because Grammar1 expects a QueryStmt at the root, while user expressions are bare relative-expressions. A fragment "anchor_now - INTERVAL 5 MINUTE" is parsed as if the user wrote "SELECT anchor_now - INTERVAL 5 MINUTE", which is a valid QueryStmt with a single projection.

Empty fragments are rejected with a dedicated message rather than being passed to the parser (which would surface a less helpful "expected expression" error).

Types

This section is empty.

Jump to

Keyboard shortcuts

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