Help us shape the future of Go! Take the 2026 Go Developer Survey

validate

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package validate decodes and validates request bodies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidationError

func IsValidationError(err error) bool

IsValidationError reports whether err contains validation failures.

func Request

func Request(r io.Reader, dst any) error

Request decodes the JSON body and runs validation when supported.

Types

type FieldError

type FieldError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

FieldError locates one failed rule on the request payload.

func FieldErrors

func FieldErrors(err error) []FieldError

FieldErrors converts an error into field-level response entries. An error that carries ozzo field detail is expanded; any other error is reported with its own message, so a domain sentinel (an invalid username, say) is not misreported as a malformed body. Only a decode failure reads as "malformed JSON".

Jump to

Keyboard shortcuts

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