validation

package
v0.1.409 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: Apache-2.0 Imports: 15 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")
	HourRange   = rule("hourrange")
	DayRange    = rule("dayrange")
	MonthRange  = rule("monthrange")
	RoleRange   = rule("rolerange")
	E164        = rule("e164")
	BCP47       = rule("bcp47")
	ISOCurrency = rule("isocurrency")
	Timezone    = rule("tz")
)

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 func(*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) 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