ValidatorExt

Trait ValidatorExt 

Source
pub trait ValidatorExt: Send + Sync {
    // Required method
    fn validate(&self) -> Result<()>;
}
Expand description

Extension trait for validating messages using prost-reflect.

The implementation is provided for the prost_reflect::ReflectMessage trait:

 use prost_reflect_validate::ValidatorExt;
 use example_proto::ExampleMessage;

 match ExampleMessage::default().validate() {
    Ok(_) => println!("Validation passed"),
    Err(e) => eprintln!("Validation failed: {}", e),
 }
 let msg = ExampleMessage{content: "Hello, world!".to_string()};
 match msg.validate() {
    Ok(_) => println!("Validation passed"),
    Err(e) => eprintln!("Validation failed: {}", e),
 }

Required Methods§

Source

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

Implementors§