Skip to main content

Validate

Trait Validate 

Source
pub trait Validate {
    // Required method
    fn validate(&self) -> Result<(), ValidationError>;
}
Expand description

Compile-time validation for Protocol Buffer messages with generated validators.

This trait is implemented by prost-protovalidate-build for messages that have only standard buf.validate rules (no CEL expressions). Validators run through monomorphized direct field access at runtime — no prost-reflect transcoding, no CEL interpreter on the hot path. For messages using CEL expressions or a mix of standard + CEL rules, use the runtime Validator instead.

§Generated violations

Violations produced by generated validators have identical Violation::field_path(), Violation::rule_id(), Violation::rule_path(), and Violation::message() as the runtime validator. The enrichment accessors (Violation::field_descriptor(), Violation::field_value(), Violation::rule_descriptor(), Violation::rule_value()) return None — these require runtime reflection data not available in generated code.

§Errors

Returns ValidationError containing all constraint violations found.

Required Methods§

Source

fn validate(&self) -> Result<(), ValidationError>

Validate this message against its buf.validate rules.

§Errors

Returns ValidationError containing all constraint violations found.

Implementors§