validate

module
v0.0.0-...-afc29fe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2024 License: MIT

README

Example of GRPC validation

Using

install plugin protoc-gen-validate

go install github.com/envoyproxy/protoc-gen-validate@v0.6.7

Automatic generation of the validation file *.validate.go file

protoc --validate_opt=paths=source_relative --validate_out=lang=go:. *.proto

Use in server-side methods

err := req.Validate()
if err != nil {
    return nil, status.Errorf(codes.InvalidArgument, "%v", err)
}

Click for more constraint rules.


Running

# run grpc server
cd server && go run main.go

# run grpc client
cd client && go run main.go

Directories

Path Synopsis
proto

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL