Skip to main content

ValidateRequest

Trait ValidateRequest 

Source
pub trait ValidateRequest {
    // Required method
    fn validate_inner(&self) -> Result<(), Status>;
}
Expand description

Extension trait that calls Validate::validate on the inner message of a tonic::Request and maps any ValidationError to a tonic::Status with Code::InvalidArgument.

Applies to handlers whose request shape is tonic::Request<T> — unary and server-streaming RPCs. For client-streaming and bidirectional RPCs where the request is tonic::Request<tonic::Streaming<T>>, see the per-message pattern in the module-level docs.

Required Methods§

Source

fn validate_inner(&self) -> Result<(), Status>

Validate the inner message of this gRPC request.

§Errors

Returns a tonic::Status with Code::InvalidArgument if any validation rule failed. With the tonic-types feature on, the status carries a google.rpc.BadRequest detail with one FieldViolation per Violation.

Implementations on Foreign Types§

Source§

impl<T: Validate> ValidateRequest for Request<T>

Implementors§