Documentation
¶
Overview ¶
Package validate provides a Connect interceptor that enforces protovalidate (buf.validate) field rules at the RPC boundary.
It is the WIRE arm of forge's "one declaration, three enforcement points" contract: a rule declared once on a proto field — `int64 amount_cents = 1 [(buf.validate.field).int64.gte = 0];` — is enforced here on every request BEFORE the handler runs (invalid requests are rejected with CodeInvalidArgument), while the same rule also projects to a DB CHECK at entity birth and a zod validator in the generated form.
The interceptor is generic: it validates whatever protovalidate rules a request message carries, so it covers the full protovalidate surface (CEL, string formats, repeated/map rules, ...) — not just the subset forge projects to the DB/form layers. Wiring is a single line in the generated serve composition root; the machinery lives here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Interceptor ¶
func Interceptor() (connect.Interceptor, error)
Interceptor returns a Connect interceptor that validates every request message against its protovalidate rules. It builds one shared protovalidate.Validator (which compiles each message's rules once and caches them), so the interceptor is cheap per-call. Returns an error only if the validator itself cannot be constructed.
Types ¶
This section is empty.