validate

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2025 License: MIT Imports: 5 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Struct

func Struct[T any](ctx context.Context, obj T, fieldRules ...FieldRule[T]) error

func TranslateError

func TranslateError(ctx validatecontext.Context, err error) error

Types

type FieldRule

type FieldRule[T any] interface {
	Validate(ctx validatecontext.Context, obj T) *errors.FieldError
}

func Field

func Field[T any, V any](structField field.StructField[T, V], rules ...Rule[V]) FieldRule[T]

func If

func If[T any](ifFunc func(v T) bool, fieldRules ...FieldRule[T]) FieldRule[T]

func IfFieldTypeOf

func IfFieldTypeOf[R any, T any, V any](structField field.StructField[T, V], fieldRules ...FieldRule[R]) FieldRule[T]

func ObjectField

func ObjectField[T any, V any](
	structField field.StructField[T, V],
	fieldRules ...FieldRule[V],
) FieldRule[T]

func ObjectSliceField

func ObjectSliceField[T any, V any](
	field field.StructField[T, []V],
	fieldRules ...FieldRule[V],
) FieldRule[T]

func SliceField

func SliceField[T any, V any](
	field field.StructField[T, []V],
	rules ...Rule[V],
) FieldRule[T]

type Rule

type Rule[T any] interface {
	Validate(ctx validatecontext.Context, v T) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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