glue

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoolBuilder

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

BoolBuilder accumulates boolean validation rules.

func NewBoolBuilder

func NewBoolBuilder(engine *core.Engine) *BoolBuilder

NewBoolBuilder creates a new BoolBuilder with the base type rule.

func (*BoolBuilder) Build

func (b *BoolBuilder) Build() func(any) error

type IntBuilder

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

IntBuilder accumulates integer validation rules.

func NewIntBuilder

func NewIntBuilder(exact bool, engine *core.Engine) *IntBuilder

NewIntBuilder creates a new IntBuilder with the base type rule.

func (*IntBuilder) Build

func (b *IntBuilder) Build() func(any) error

func (*IntBuilder) MaxInt

func (b *IntBuilder) MaxInt(n int64) *IntBuilder

func (*IntBuilder) MinInt

func (b *IntBuilder) MinInt(n int64) *IntBuilder

type SliceBuilder

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

SliceBuilder accumulates slice validation rules.

func (*SliceBuilder) Build

func (b *SliceBuilder) Build() func(any) error

func (*SliceBuilder) ForEach

func (b *SliceBuilder) ForEach(elemValidator func(any) error) *SliceBuilder

func (*SliceBuilder) ForEachRules

func (b *SliceBuilder) ForEachRules(inner ...types.Rule) *SliceBuilder

ForEachRules applies inner rules to each slice element. This form is cache-friendly (no function args).

func (*SliceBuilder) ForEachStringBuilder

func (b *SliceBuilder) ForEachStringBuilder(sb *StringBuilder) *SliceBuilder

ForEachStringBuilder copies rules from a StringBuilder as element rules.

func (*SliceBuilder) Length

func (b *SliceBuilder) Length(n int) *SliceBuilder

func (*SliceBuilder) MaxLength

func (b *SliceBuilder) MaxLength(n int) *SliceBuilder

func (*SliceBuilder) MinLength

func (b *SliceBuilder) MinLength(n int) *SliceBuilder

type StringBuilder

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

StringBuilder accumulates string validation rules.

func (*StringBuilder) Build

func (b *StringBuilder) Build() func(any) error

func (*StringBuilder) Length

func (b *StringBuilder) Length(n int) *StringBuilder

func (*StringBuilder) MaxLength

func (b *StringBuilder) MaxLength(n int) *StringBuilder

func (*StringBuilder) MaxRunes

func (b *StringBuilder) MaxRunes(n int) *StringBuilder

func (*StringBuilder) MinLength

func (b *StringBuilder) MinLength(n int) *StringBuilder

func (*StringBuilder) MinRunes

func (b *StringBuilder) MinRunes(n int) *StringBuilder

func (*StringBuilder) OneOf

func (b *StringBuilder) OneOf(vals ...string) *StringBuilder

func (*StringBuilder) Regex

func (b *StringBuilder) Regex(pat string) *StringBuilder

type Validate

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

Validate provides the main validation API that glues together the core engine with specific validator implementations.

func New

func New() *Validate

New creates a new Validate instance with sensible defaults.

func NewBare

func NewBare() *Validate

NewBare returns a Validate without installing a default translator. Useful for advanced setups that manage translations differently.

func NewWithTranslator

func NewWithTranslator(tr translator.Translator) *Validate

NewWithTranslator returns a Validate configured with the provided translator while keeping other defaults.

func (*Validate) Bool

func (v *Validate) Bool() *BoolBuilder

Bool returns a boolean validator builder.

func (*Validate) FromRules

func (v *Validate) FromRules(
	rules []string,
) (func(any) error, error)

FromRules creates a validator function from rule tokens.

func (*Validate) FromTag

func (v *Validate) FromTag(tag string) (func(any) error, error)

FromTag compiles a single tag string into a validator function.

func (*Validate) Int

func (v *Validate) Int() *IntBuilder

Int returns an integer validator builder.

func (*Validate) Int64

func (v *Validate) Int64() *IntBuilder

Int64 returns an int64 validator builder.

func (*Validate) PathSeparator

func (v *Validate) PathSeparator(sep string) *Validate

PathSeparator customizes the nested field path separator.

func (*Validate) Slice

func (v *Validate) Slice() *SliceBuilder

Slice returns a slice validator builder.

func (*Validate) String

func (v *Validate) String() *StringBuilder

String returns a string validator builder.

func (*Validate) WithCustomRule

func (v *Validate) WithCustomRule(
	name string, rule func(any) error,
) *Validate

WithCustomRule returns a copy with an additional custom rule.

func (*Validate) WithTranslator

func (v *Validate) WithTranslator(t translator.Translator) *Validate

WithTranslator sets a Translator and returns a new Validate.

Jump to

Keyboard shortcuts

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