Documentation
¶
Index ¶
- type BoolBuilder
- type IntBuilder
- type SliceBuilder
- func (b *SliceBuilder) Build() func(any) error
- func (b *SliceBuilder) ForEach(elemValidator func(any) error) *SliceBuilder
- func (b *SliceBuilder) ForEachRules(inner ...types.Rule) *SliceBuilder
- func (b *SliceBuilder) ForEachStringBuilder(sb *StringBuilder) *SliceBuilder
- func (b *SliceBuilder) Length(n int) *SliceBuilder
- func (b *SliceBuilder) MaxLength(n int) *SliceBuilder
- func (b *SliceBuilder) MinLength(n int) *SliceBuilder
- type StringBuilder
- func (b *StringBuilder) Build() func(any) error
- func (b *StringBuilder) Length(n int) *StringBuilder
- func (b *StringBuilder) MaxLength(n int) *StringBuilder
- func (b *StringBuilder) MaxRunes(n int) *StringBuilder
- func (b *StringBuilder) MinLength(n int) *StringBuilder
- func (b *StringBuilder) MinRunes(n int) *StringBuilder
- func (b *StringBuilder) OneOf(vals ...string) *StringBuilder
- func (b *StringBuilder) Regex(pat string) *StringBuilder
- type Validate
- func (v *Validate) Bool() *BoolBuilder
- func (v *Validate) FromRules(rules []string) (func(any) error, error)
- func (v *Validate) FromTag(tag string) (func(any) error, error)
- func (v *Validate) Int() *IntBuilder
- func (v *Validate) Int64() *IntBuilder
- func (v *Validate) PathSeparator(sep string) *Validate
- func (v *Validate) Slice() *SliceBuilder
- func (v *Validate) String() *StringBuilder
- func (v *Validate) WithCustomRule(name string, rule func(any) error) *Validate
- func (v *Validate) WithTranslator(t translator.Translator) *Validate
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 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) 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 ¶
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 ¶
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.