Skip to content

Latest commit

 

History

History

README.md

The Buf logo

Protovalidate examples

Protovalidate provides standard annotations to validate common rules on messages and fields, as well as the ability to use CEL to write custom rules. It's the next generation of protoc-gen-validate, the only widely used validation library for Protobuf.

Supplementing its documentation, this repository provides quickstart code exercises and reference examples for its use.

Protovalidate quickstart

Quickstart code for Protovalidate's Quickstart is available in the following languages. Each contains a start directory with a starting state and finish with a working solution.

Compiling and generating code

Example code for Adding Protovalidate to Protobuf projects is available for the following build tools:

Standard rules

Example code for Using Protovalidate standard rules provides a library of Protobuf files demonstrating Protovalidate's built-in standard rules.

Custom rules

Example code for Custom CEL rules provides a library of Protobuf files demonstrating Common Expression Language (CEL)-based custom rules.

Predefined rules

Quickstart code for Predefined rules shows how to create your own reusable rules. The only code changed during the tutorial is in Protobuf files, so no additional language examples are necessary. It contains a start directory with a starting state and finish with a working solution.

Using Protovalidate in RPC APIs

Quickstart code showing how to use Protovalidate in unary RPCs is available in the following languages. Each contains a start directory with a starting state and finish with a working solution.

Using Protovalidate in Kafka

Quickstart code for Using Protovalidate in Kafka with Bufstream shows how to enforce schemas within the Bufstream Kafka broker. The only code changed during the tutorial is in Protobuf and YAML files, so only a Go example is provided. It contains a start directory with a starting state and finish with a working solution.