verify

package module
v0.0.0-...-d1e6209 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 2 Imported by: 0

README

Verify

Verify is a validation library for Go 1.24+.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmpty = errors.New("value is empty")
	ErrNil   = errors.New("value is nil")
)

Functions

func Error

func Error(vc Context) error

func Field

func Field[T any](vc Context, field *T, vs ...Verifier[T])

func FieldOpt

func FieldOpt[T any](vc Context, field **T, vs ...Verifier[T])

func Slice

func Slice[T any](ctx Context, s []T) iter.Seq2[Context, T]

Types

type Context

type Context interface {
	Write(field any, err error)
	Report() Report
}

func New

func New[T any](r *T) Context

type Report

type Report struct {
	Field    string
	Errors   []error
	Children []Report
}

type SeqContext

type SeqContext[T any] struct {
	Index int
	Value T
}

func (*SeqContext[T]) Report

func (c *SeqContext[T]) Report() Report

func (*SeqContext[T]) Write

func (c *SeqContext[T]) Write(field any, err error)

type StructContext

type StructContext struct{}

func Struct

func Struct(value any) *StructContext

func (*StructContext) Report

func (c *StructContext) Report() Report

func (*StructContext) Write

func (c *StructContext) Write(field any, err error)

type Verifier

type Verifier[T any] func(field T) error

func (Verifier[T]) Or

func (f Verifier[T]) Or(err error) Verifier[T]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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