validation

package
v0.1.924 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Validate          = rule("validate")
	Recurse           = rule("recurse")
	NonNilPtr         = rule("nnpt")
	NonZero           = rule("nz")
	UTC               = rule("utc")
	MinuteRange       = rule("minuterange")
	HourRange         = rule("hourrange")
	DayRange          = rule("dayrange")
	MonthRange        = rule("monthrange")
	WeekDayRange      = rule("weekdayrange")
	WeekRange         = rule("weekrange")
	DayInMinutesRange = rule("dayinminutesrange")
	RGBARange         = rule("rgbarange")
	RoleRange         = rule("rolerange")
	E164              = rule("e164")
	BCP47             = rule("bcp47")
	ISOCurrency       = rule("isocurrency")
	Timezone          = rule("tz")
	PercentRange      = rule("percentrange")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	contract.ValidationOperator
}

func NewClient

func NewClient(opts ClientOptions) (Client, error)

type ClientOption added in v0.1.338

type ClientOption = contract.Opt[ClientOptions]

func WithToRegister added in v0.1.338

func WithToRegister(x ToRegister) ClientOption

type ClientOptions added in v0.1.338

type ClientOptions struct {
	T ToRegister
}

func ApplyClientOptions added in v0.1.338

func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions

type DefaultTool added in v0.1.11

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(client Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) RunGuards added in v0.1.830

func (d *DefaultTool) RunGuards(ctx context.Context, opts contract.RunGuardsOptions) error

RunGuards executes guard calls in order.

func (*DefaultTool) Validate added in v0.1.11

func (d *DefaultTool) Validate(ctx context.Context, key string, v any) error

Validate runs all registered validators on a struct tagged with the provided tag key.

type Rule

type Rule = string

type ToRegister added in v0.1.338

type ToRegister map[Rule]ValidatorFunc

type Tool added in v0.1.245

type Tool interface {
	Client
}

type ValidatorFunc

type ValidatorFunc func(v reflect.Value, field string) error

func InRange

func InRange(opts contract.RangeOptions) ValidatorFunc

InRange returns a ValidatorFunc that requires the value to be within the specified range.

func Require

Require returns a ValidatorFunc that requires the value to meet the specified conditions.

func RequireBCP47

func RequireBCP47() ValidatorFunc

RequireBCP47 returns a ValidatorFunc that requires the value to be a valid BCP47 language tag.

func RequireE164Phone

func RequireE164Phone() ValidatorFunc

RequireE164Phone returns a ValidatorFunc that requires the value to be a valid E.164 phone number.

func RequireISOCurrency

func RequireISOCurrency() ValidatorFunc

RequireISOCurrency returns a ValidatorFunc that requires the value to be a valid ISO 4217 currency code.

func RequireTimezone added in v0.1.347

func RequireTimezone() ValidatorFunc

RequireTimezone returns a ValidatorFunc that requires the value to be a valid IANA timezone string.

func RequireUTCDate

func RequireUTCDate() ValidatorFunc

RequireUTCDate returns a ValidatorFunc that requires the value to be a valid UTC date.

Jump to

Keyboard shortcuts

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