validation

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error represents a single field validation error.

func (Error) Error

func (e Error) Error() string

type Errors

type Errors []Error

Errors is a collection of validation errors.

func (Errors) Error

func (e Errors) Error() string

type Rule

type Rule func(value reflect.Value, param string) error

Rule validates a field value given an optional parameter.

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates structs based on "validate" struct tags.

func New

func New() *Validator

New creates a new Validator with built-in rules.

func (*Validator) Register

func (v *Validator) Register(name string, rule Rule)

func (*Validator) Validate

func (v *Validator) Validate(target any) Errors

Jump to

Keyboard shortcuts

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