internal

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDirective = errors.New("malformed directive")

ErrDirective indicates a malformed or misapplied dv8 directive: a bug in the tag, not in the data.

Functions

func Compile added in v0.3.0

func Compile(refType reflect.Type) error

Compile validates the dv8 directives declared on a type, recursing into nested types, and builds its cached execution plan. Errors wrap ErrDirective. The result is cached per type.

func Validate

func Validate(ctx context.Context, data any) error

Validate takes in a reference to a data struct (pointer, map of, slice of) and validates each of its fields against their dv8 field tags. It recurses into nested structs. A nil ctx is tolerated and replaced with context.Background.

Types

type Directive added in v0.4.0

type Directive struct {
	Prefixes []string // "each" and "key" prefixes, outermost first
	Name     string   // "notzero", "trim", "tolower", "toupper", "len", "val", "oneof", "regexp", "default", "delegate", "on", "-", or the verbatim text of an unrecognized directive
	Operator string   // the comparison operator of a "len" or "val" directive
	Value    string   // the operand: the bound, pattern, set of values, default value, or field name
}

Directive is one parsed directive of a dv8 struct tag.

func ParseTag added in v0.4.0

func ParseTag(tag string) []Directive

ParseTag parses the value of a dv8 struct tag into its directives. It performs no validity checks; Compile is the arbiter of validity.

type Validator added in v0.1.4

type Validator interface {
	Validate(ctx context.Context) error
}

Validator implements a single method that returns an error if a struct is invalid. DV8 calls this method during validation on any type in the object graph that implements it.

Jump to

Keyboard shortcuts

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