validate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validator

func Validator(validators ...ValidatorFunc) middleware.Middleware

Validator returns a middleware that performs validation on requests. It validates requests that implement Validate and any custom validators. Example usage:

buf validate(https://github.com/bufbuild/protovalidate): import "buf.build/go/protovalidate" import "google.golang.org/protobuf/proto"

Validator(func(v any) error {
    if msg, ok := v.(proto.Message); ok {
        return protovalidate.Validate(msg)
	}
    return nil
})

Google AIP field behavior validate(https://google.aip.dev/203): import "go.einride.tech/aip/fieldbehavior" import "google.golang.org/protobuf/proto"

Validator(func(v any) error {
    if msg, ok := v.(proto.Message); ok {
        return fieldbehavior.ValidateRequiredFields(msg)
	}
    return nil
})

Types

type ValidatorFunc

type ValidatorFunc func(v any) error

ValidatorFunc defines a validation function type.

Jump to

Keyboard shortcuts

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