validate

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 8 Imported by: 0

README

Validator Middleware for Forge Project

This module provides a middleware for Forge to validate request parameters, using schema defined in .proto files.

The middleware validates requests with the schema definitions and validation functions provided by Protovalidate.

Protovalidate requires no validation code generation at build time. The middleware also invokes Validate() error when a request implements that interface, so hand-written validators and code generated by other tools participate without any extra dependency.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrValidation = errors.MustDefine(errors.KindInvalidArgument, errors.Domain, "VALIDATION_FAILED")

ErrValidation identifies a request rejected by a validator.

Functions

func PerMessageProtoValidateStream

func PerMessageProtoValidateStream() middleware.StreamMiddleware

PerMessageProtoValidateStream validates every message received on a stream.

This suits client and bidirectional streaming, where each message is a separate input worth checking. A message that fails validation fails that RecvMsg with a BadRequest error and leaves the stream open, so the handler decides whether to continue or return. The initial request, when a method has one, is validated too.

func ProtoValidate

func ProtoValidate() middleware.UnaryMiddleware

ProtoValidate is a middleware that validates the request message with protovalidate(https://github.com/bufbuild/protovalidate)

func ProtoValidateStream

func ProtoValidateStream() middleware.StreamMiddleware

ProtoValidateStream validates the initial request of a stream, once, before the handler runs.

This suits server-streaming methods, where the client sends one request and then only receives. For client and bidirectional streaming the initial request is nil and nothing is validated — use PerMessageProtoValidateStream there.

Types

This section is empty.

Jump to

Keyboard shortcuts

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