validation

package
v0.133.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package validation provides struct-tag validation helpers and custom validator registration for internal config types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterValidationFunc

func RegisterValidationFunc(tag string, fn Func) error

RegisterValidationFunc registers a custom validation tag for use in struct field tags.

func Validate

func Validate(v any) error

Validate applies validator rules, custom tag handlers, and scalar value validation. Custom traversal respects the -, nostructlevel, and structonly tags. Opaque structs accept required, omitempty, and registered custom field rules.

Types

type Func

type Func func(v any, param string) error

Func adapts custom field validation to the tag+parameter shape used in struct tags.

type TextError

type TextError struct {
	Err error
}

func (TextError) Error

func (e TextError) Error() string

Error returns the wrapped error text.

func (TextError) Unwrap

func (e TextError) Unwrap() error

Unwrap exposes the wrapped error for errors.Is and errors.As.

type ValueValidator added in v0.125.0

type ValueValidator interface {
	ValidateValue() error
}

ValueValidator lets scalar configuration types validate themselves without a struct tag.

Jump to

Keyboard shortcuts

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