Skip to main content

Crate protovalidate_buffa

Crate protovalidate_buffa 

Source
Expand description

Runtime companion for protoc-gen-protovalidate-buffa.

Provides the Validate trait, the ValidationError / Violation / FieldPath types returned from generated validate() methods, the cel module of thin helpers that compile-time-expanded CEL rules call into (scalar widening, Duration/Timestamp converters, now), and the rules module of pure-Rust helpers used by generated code (UUID / ULID / IP / URI / hostname checks and friends, mostly thin wrappers over uuid, ulid, ipnet, and fluent-uri).

There is no CEL interpreter at runtime: the paired protoc-gen-protovalidate-buffa plugin transpiles every CEL rule to native Rust at codegen time. Generated validate() methods are direct field-access checks without per-call dynamic CEL Value materialization. Rules that need scratch state, such as repeated-value uniqueness, allocate it directly.

ValidationError carries three orthogonal signals:

  • violations: list of per-field rule failures (the common case).
  • compile_error: non-empty when the codegen plugin detected a schema-level mismatch (rule type / field type, duplicate / unknown fields in message.oneof, CEL referencing a non-existent field).
  • runtime_error: non-empty when a rule’s precondition could not be evaluated (e.g. bytes.pattern on non-UTF-8 input, or a CEL rule that compiled-time analysis flagged as always-runtime-error such as dyn(this).<unknown_field>).

The full upstream protovalidate-conformance suite (2872 cases, covering proto2, proto3, and editions 2023) passes against code emitted by the paired plugin.

Re-exports§

pub use protovalidate_buffa_protos::buf::validate as proto;
pub use buffa;
pub use chrono;
pub use regex;

Modules§

cel
Helpers used by compile-time-expanded CEL rules emitted by the plugin.
rules

Macros§

field_path

Structs§

DecodeViolationsError
A matching validation detail could not be decoded within receiver limits.
FieldPath
FieldPathElement
ValidationError
Violation

Enums§

FieldType
Subscript

Traits§

Validate

Functions§

decode_violations
Decodes a canonical validation detail from a Connect or gRPC error.

Attribute Macros§

connect_impl
#[connect_impl] — attribute macro applied to a Connect service impl block that validates the borrowed request view at the top of every handler method, without converting it to an owned message. Requires Validate on the generated view type. Guarantees protovalidate runs for every RPC without relying on per-handler discipline.