v

package
v0.0.0-...-b5b159f Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Args

func Args[Value any](fn func(validator *Set[Value])) func(Value) (Value, error)

func Struct

func Struct[Source any, Value any](grp *Set[Source], get func(Source) Value, next func(*Set[Value]))

Types

type FloatV

type FloatV[Value interface {
	constraints.Float
}] struct {
	*NumericV[Value, FloatValidator[Value]]
}

func (*FloatV[Value]) Eq

func (v *FloatV[Value]) Eq(check, epsi Value) FloatValidator[Value]

type FloatValidator

type FloatValidator[Value interface {
	constraints.Float
}] interface {
	NumericValidator[Value, FloatValidator[Value]]

	Eq(Value, epsilon Value) FloatValidator[Value]
}

func Float

func Float[Source any](grp *Set[Source], get func(Source) float64) FloatValidator[float64]

type GenericV

type GenericV[Value any, Derived any] struct {
	// contains filtered or unexported fields
}

func NewGenericV

func NewGenericV[Value any, Derived any](derived Derived) *GenericV[Value, Derived]

func (*GenericV[Value, Derived]) Check

func (v *GenericV[Value, Derived]) Check(check func(value Value) error) Derived

func (*GenericV[Value, Derived]) Err

func (v *GenericV[Value, Derived]) Err(err func(value Value, check Value, err error) error) Derived

Always manipulates the last requirement's err/message.

func (*GenericV[Value, Derived]) Msg

func (v *GenericV[Value, Derived]) Msg(msg string) Derived

Always manipulates the last requirement's err/message.

func (*GenericV[Value, Derived]) Validate

func (v *GenericV[Value, Derived]) Validate(value Value) error

type GenericValidator

type GenericValidator[Value any, Derived any] interface {
	Msg(msg string) Derived
	Err(func(value Value, check Value, err error) error) Derived
	Check(func(value Value) error) Derived
}

type IntegerV

type IntegerV[Value interface {
	constraints.Integer
}] struct {
	*NumericV[Value, IntegerValidator[Value]]
}

func (*IntegerV[Value]) Eq

func (v *IntegerV[Value]) Eq(req Value) IntegerValidator[Value]

func (*IntegerV[Value]) In

func (v *IntegerV[Value]) In(req ...Value) IntegerValidator[Value]

type IntegerValidator

type IntegerValidator[Value interface {
	constraints.Integer
}] interface {
	NumericValidator[Value, IntegerValidator[Value]]

	Eq(Value) IntegerValidator[Value]
	In(values ...Value) IntegerValidator[Value]
}

func Int

func Int[Source any](grp *Set[Source], get func(Source) int) IntegerValidator[int]

type NumericV

type NumericV[Value interface {
	constraints.Integer | constraints.Float
}, Derived any] struct {
	*GenericV[Value, Derived]
}

func NewNumericV

func NewNumericV[Value interface {
	constraints.Integer | constraints.Float
}, Derived any](derived Derived) *NumericV[Value, Derived]

func (*NumericV[Value, Derived]) BetweenNeq

func (v *NumericV[Value, Derived]) BetweenNeq(min, max Value) Derived

func (*NumericV[Value, Derived]) Gt

func (v *NumericV[Value, Derived]) Gt(req Value) Derived

func (*NumericV[Value, Derived]) Lt

func (v *NumericV[Value, Derived]) Lt(req Value) Derived

func (*NumericV[Value, Derived]) Negative

func (v *NumericV[Value, Derived]) Negative() Derived

func (*NumericV[Value, Derived]) NonNegative

func (v *NumericV[Value, Derived]) NonNegative() Derived

func (*NumericV[Value, Derived]) NonPositive

func (v *NumericV[Value, Derived]) NonPositive() Derived

func (*NumericV[Value, Derived]) Positive

func (v *NumericV[Value, Derived]) Positive() Derived

func (*NumericV[Value, Derived]) Zero

func (v *NumericV[Value, Derived]) Zero() Derived

type NumericValidator

type NumericValidator[Numeric interface {
	constraints.Integer | constraints.Float
}, Derived any] interface {
	Gt(check Numeric) Derived
	Lt(check Numeric) Derived
	Positive() Derived
	Negative() Derived
	NonPositive() Derived
	NonNegative() Derived
	Zero() Derived
	BetweenNeq(min, max Numeric) Derived
}

type Set

type Set[Value any] struct {
	// contains filtered or unexported fields
}

type StringValidator

func String

func String[Source any](grp *Set[Source], get func(Source) string) StringValidator

Jump to

Keyboard shortcuts

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