prost-validate
A protobuf library extending prost and prost-reflect with validation support.
This a rust implementation protoc-gen-validate.
Usage
It currently supports validation using reflection.
It must be used with prost and prost-reflect generated code.
All validation rules are documented in the proto file or in the protoc-gen-validate documentation.
Proto definition
syntax = "proto3";
package validate.example;
import "validate/validate.proto";
message ExampleMessage {
string content = 1 [(validate.rules).string = {const: "Hello, world!"}];
}
Validation
It exposes a single extension trait ValidatorExt which can be used to validate protobuf reflect messages.
Ouput
Validation failed: validate.example.ExampleMessage.content: must be Hello, world!
Validation passed
Minimum Supported Rust Version
Rust 1.64 or higher.
The minimum supported Rust version may be changed in the future, but it will be done with a minor version bump.