validation

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 16 Imported by: 0

README

GoForj validation gopher with a checklist

Typed fluent validation with reusable rules and useful field errors.

Go Reference MIT License CI Security Go 1.24 or newer Version v0.2.0 Measured unit coverage Executed Go tests

Keep field names, values, and constraints together. Validate decoded requests, configuration, and domain values using ordinary Go code, with no runtime dependencies.

Feature What it provides
 Typed chains Typed builders for text, numbers, exact decimals, time, and collections.
 Reusable rules Compose rules and plug in custom validators without global registration.
 Format checks Common formats and character checks directly in the fluent chain.
 Field errors Ordered paths, stable codes, custom messages, and localization hooks.
 Optional inputs Distinguish omitted fields, explicit null, and supplied zero values.

Quick start

Requires Go 1.24 or newer.

go get github.com/goforj/validation@v0.2.0

The complete registration program defines the Registration model and imports the library:

req := Registration{
	Name:  "Ada",
	Email: "ada@example.com",
	Age:   36,
	Terms: true,
}

err := validation.Validate(
	validation.String("name", req.Name).
		Required().
		Min(2).
		Max(100),

	validation.String("email", req.Email).
		Required().
		IsEmail(),

	validation.Number("age", req.Age).Min(18),
	validation.Bool("terms", req.Terms).Accepted(),
)

fmt.Println(err)
// <nil>

How it works

  • Values are explicit. Zero and false are ordinary values. Rules evaluate empty strings unless you use a lazy condition to omit a field. Required checks run before content checks.
  • Errors stay useful. Validation collects the first violation per field by default. Use New().CollectAll() for all content failures or StopOnFirstError() to stop globally. Custom messages retain their machine code. Unexpected rule errors abort evaluation and remain operational errors.
  • Custom rules fit the same chain. Implement Rule[T] with Validate(T) error, or use a function adapter. Return validation.Invalid for an input failure. Add RuleWithContext[T] for dependencies that need cancellation.
  • Evaluation is local. Builders can be branched and reused. Input slices and application dependencies are borrowed. Coordinate concurrent mutation in your application.

See validation contracts for presence, formats, paths, configuration errors, ownership, and cancellation.

Runnable examples

Run from the repository root with go run ./examples/<name>. Tests verify every program's output.

quickstart · formats · patch · nested · custom · context · domain · errors · constraints · advanced · time · presence · moreformats · policies · decimal · currency

API index

Group Functions
Values String · Number · Bool · Validate
Formats IsEmail · IsURL · IsUUID · IsUUIDv4 · IsUUIDv7 · IsIP · IsIPv4 · IsIPv6 · IsJSON · IsBase64
Conditions When
Collections Group · Slice · Each
Custom rules Using · Invalid
Context ValidateContext · Check
Domain values Value · RuleFunc · ContextRuleFunc
Errors Label · Message · First · Messages · Issues
Constraints Required · RequiredIf · NotBlank · Min · Max · In · Equal · Match · Accepted
Text constraints Len · Contains · NotContains · StartsWith · EndsWith · NotEqual · NotIn
Numeric constraints GreaterThan · LessThan · MultipleOf
Collection constraints Map · Unique · UniqueBy · HasKey · OnlyKeys
Dates and times Time · Before · After · IsDate · IsDateIn
Optional inputs Presence · Nullable · Optional · Provided · Null · IsPresent · IsNull · Get
More formats IsULID · IsHostname · IsCIDR · IsMAC · IsE164 · IsBase64URL · IsAlpha · IsAlphanumeric · IsDigits · IsASCII · IsLowercase · IsUppercase · IsUTF8
Composition Any · All · Not
Evaluation policy New · CollectAll · StopOnFirstError · FormatMessages
Exact decimals Decimal · MaxScale
Currencies Currency · USD · EUR · GBP

Values

String · Number · Bool · Validate

String starts a deferred chain for a borrowed application value.

req := Registration{
	Name:  "Ada",
	Email: "ada@example.com",
	Age:   36,
	Terms: true,
}

err := validation.Validate(
	validation.String("name", req.Name).
		Required().
		Min(2).
		Max(100),

	validation.String("email", req.Email).
		Required().
		IsEmail(),

	validation.Number("age", req.Age).Min(18),
	validation.Bool("terms", req.Terms).Accepted(),
)

fmt.Println(err)
// <nil>

Formats

IsEmail · IsURL · IsUUID · IsUUIDv4 · IsUUIDv7 · IsIP · IsIPv4 · IsIPv6 · IsJSON · IsBase64

IsEmail requires a bare ASCII mailbox with a dotted domain.

uuidV4 := "550e8400-e29b-41d4-a716-446655440000"
uuidV7 := "0190bde7-5ad0-7000-8000-000000000001"

err := validation.Validate(
	validation.String("email", "ada@example.com").
		IsEmail(),
	validation.String("site", "https://goforj.dev").
		IsURL(),

	validation.String("id", uuidV4).
		IsUUID(),
	validation.String("trace_id", uuidV4).
		IsUUIDv4(),
	validation.String("request_id", uuidV7).
		IsUUIDv7(),

	validation.String("host", "::1").IsIP(),
	validation.String("ip", "192.0.2.1").IsIPv4(),
	validation.String("ipv6", "2001:db8::1").IsIPv6(),

	validation.String("metadata", `{"source":"web"}`).
		IsJSON(),
	validation.String("cursor", "YWJj").IsBase64(),
)

fmt.Println(err)
// <nil>

Conditions

When

When evaluates the callback lazily only when condition is true.

return validation.Validate(
	validation.When(
		req.Email != nil,
		func() validation.Field {
			email := *req.Email
			return validation.String("email", email).
				Required().
				IsEmail()
		},
	),
)

Collections

Group · Slice · Each

Group prefixes child paths with a literal parent label.

items := []Item{
	{SKU: "book", Quantity: 0},
}

err := validation.Validate(
	validation.Group("address",
		validation.String("city", "").Required(),
	),

	validation.Slice("items", items).
		Required().
		Max(100).
		Each(func(item Item) []validation.Field {
			return []validation.Field{
				validation.String("sku", item.SKU).
					Required(),
				validation.Number(
					"quantity",
					item.Quantity,
				).Min(1),
			}
		}),
)

failures := err.(*validation.Errors)
for _, issue := range failures.Issues() {
	fmt.Println(issue.Path, issue.Code)
}
// address.city required
// items.0.quantity min

Custom rules

Using · Invalid

Using attaches a reusable validator for the exact value type.

// AllowedDomain requires the configured company domain.
type AllowedDomain struct {
	Domain string
}

// Validate rejects addresses outside the company.
func (r AllowedDomain) Validate(value string) error {
	_, domain, ok := strings.Cut(value, "@")
	if !ok || !strings.EqualFold(domain, r.Domain) {
		return validation.Invalid(
			"email_domain",
			"Use your company email address.",
		)
	}
	return nil
}
err := validation.Validate(
	validation.String("email", "ada@other.example").
		Required().
		IsEmail().
		Using(AllowedDomain{Domain: "goforj.dev"}),
)

fmt.Println(err)
// Use your company email address.

Context

ValidateContext · Check

ValidateContext evaluates with request cancellation and the configured collection policy.

unavailable := errors.New("directory unavailable")

err := validation.ValidateContext(
	context.Background(),
	validation.String("email", "ada@example.com").
		IsEmail().
		Check(
			func(ctx context.Context, v string) error {
				// A client would use ctx and v.
				return unavailable
			},
		),
)

fmt.Println(errors.Is(err, unavailable))
// true

Domain values

Value · RuleFunc · ContextRuleFunc

Value starts a deferred chain for a borrowed application value.

window := validation.RuleFunc[Delivery](
	func(value Delivery) error {
		if value.Days > 30 {
			return validation.Invalid(
				"delivery_window",
				"Choose delivery within 30 days.",
			)
		}
		return nil
	},
)

available := validation.ContextRuleFunc[Delivery](
	func(ctx context.Context, _ Delivery) error {
		return ctx.Err()
	},
)

err := validation.Validate(
	validation.Value("delivery", Delivery{Days: 7}).
		Using(window).
		Using(available),
)

fmt.Println(err)
// <nil>

Errors

Label · Message · First · Messages · Issues

Label sets the human-readable field name without changing its output path.

err := validation.Validate(
	validation.String("email", "bad").
		Label("email address").
		IsEmail().
		Message("Enter your work email address."),
)

var failures *validation.Errors
if errors.As(err, &failures) {
	fmt.Println(failures.First("email"))
	// Enter your work email address.

	fmt.Println(failures.Messages()["email"])
	// [Enter your work email address.]

	fmt.Println(failures.Issues()[0].Code)
	// email
}

Constraints

Required · RequiredIf · NotBlank · Min · Max · In · Equal · Match · Accepted

Required rejects an empty string before content rules run.

skuPattern := regexp.MustCompile(`^[A-Z]+-\d+$`)

err := validation.Validate(
	validation.String("name", "Ada").
		Required().
		NotBlank().
		Min(2).
		Max(100),

	validation.String("company", "").
		RequiredIf(false).
		Max(200),
	validation.String("role", "member").
		In("member", "admin"),

	validation.String("confirmation", "correct horse").
		Equal("correct horse"),
	validation.String("sku", "BOOK-42").
		Match(skuPattern),

	validation.Number("age", 36).Min(18).Max(120),
	validation.Bool("terms", true).Accepted(),
)

fmt.Println(err)
// <nil>

Text constraints

Len · Contains · NotContains · StartsWith · EndsWith · NotEqual · NotIn

Len requires exactly length Unicode code points.

err := validation.Validate(
	validation.String("sku", "BOOK-42").
		Len(7).
		Contains("-").
		NotContains(" ").
		StartsWith("BOOK").
		EndsWith("42"),

	validation.String("username", "ada").
		NotEqual("root").
		NotIn("admin", "system"),
)

fmt.Println(err)
// <nil>

Numeric constraints

GreaterThan · LessThan · MultipleOf

GreaterThan requires a strict lower bound in the field's numeric type.

err := validation.Validate(
	validation.Number("quantity", 12).
		GreaterThan(0).
		LessThan(100).
		MultipleOf(3),
)

fmt.Println(err)
// <nil>

Collection constraints

Map · Unique · UniqueBy · HasKey · OnlyKeys

Map starts a deferred chain for a borrowed string-keyed map.

// label checks a map value independently of its key.
func label(_ string, value string) []validation.Field {
	return []validation.Field{
		validation.String("", value).NotBlank(),
	}
}
products := []Product{{ID: 1}, {ID: 2}}
labels := map[string]string{"category": "books"}

err := validation.Validate(
	validation.Slice("tags", []string{"go", "books"}).
		Unique().
		Contains("go"),

	validation.Slice("products", products).
		Using(validation.UniqueBy(
			func(product Product) int {
				return product.ID
			},
		)),

	validation.Map("labels", labels).
		Required().
		HasKey("category").
		OnlyKeys("category").
		Each(label),
)

fmt.Println(err)
// <nil>

Dates and times

Time · Before · After · IsDate · IsDateIn

Time starts a deferred chain using instant comparisons across time zones.

starts := time.Date(2026, 11, 10, 10, 0, 0, 0, time.UTC)
ends := starts.Add(2 * time.Hour)

err := validation.Validate(
	validation.Time("starts_at", starts).
		Required().
		Before(ends).
		Min(starts).
		Max(ends).
		Equal(starts),

	validation.Time("ends_at", ends).After(starts),

	validation.String("date", "2026-11-10").
		IsDate(time.DateOnly),
	validation.String("local_time", "2026-11-10 10:00").
		IsDateIn("2006-01-02 15:04", time.UTC),
)

fmt.Println(err)
// <nil>

Optional inputs

Presence · Nullable · Optional · Provided · Null · IsPresent · IsNull · Get

Presence defers child validation until input contains a non-null value. Use an empty child path to retain path, or a named child to append a segment.

// nonBlank reuses a nonblank string rule.
func nonBlank(value string) validation.Field {
	return validation.String("", value).NotBlank()
}
var patch struct {
	Seats validation.Input[int]    `json:"seats"`
	Name  validation.Input[string] `json:"name"`
}

payload := []byte(`{"seats":0,"name":null}`)
decodeErr := json.Unmarshal(payload, &patch)
fmt.Println(decodeErr)
// <nil>

err := validation.Validate(
	validation.Presence(
		"seats",
		patch.Seats,
		func(value int) validation.Field {
			return validation.Number("", value).Min(0)
		},
	).Required(),

	validation.Presence(
		"name",
		patch.Name,
		nonBlank,
	).Nullable(),
)

fmt.Println(err)
// <nil>

fmt.Println(patch.Seats.IsPresent())
// true

fmt.Println(patch.Name.IsNull())
// true
value, present := validation.Provided(false).Get()
fmt.Println(value, present)
// false true

fmt.Println(validation.Null[string]().IsNull())
// true
var nickname *string

err := validation.Validate(
	validation.Optional(nickname, nonBlank),
)

fmt.Println(err)
// <nil>

name := "Ada"

err = validation.Validate(
	validation.Optional(&name, nonBlank),
)

fmt.Println(err)
// <nil>

More formats

IsULID · IsHostname · IsCIDR · IsMAC · IsE164 · IsBase64URL · IsAlpha · IsAlphanumeric · IsDigits · IsASCII · IsLowercase · IsUppercase · IsUTF8

IsULID requires a case-insensitive 128-bit ULID.

id := "01ARZ3NDEKTSV4RRFFQ69G5FAV"

err := validation.Validate(
	validation.String("id", id).
		IsULID(),

	validation.String("host", "api.example.com").
		IsHostname(),
	validation.String("network", "192.0.2.0/24").
		IsCIDR(),
	validation.String("device", "00:11:22:33:44:55").
		IsMAC(),

	validation.String("phone", "+14155552671").IsE164(),
	validation.String("token", "__8").IsBase64URL(),

	validation.String("name", "Ada").IsAlpha(),
	validation.String("sku", "A123").IsAlphanumeric(),
	validation.String("pin", "012345").IsDigits(),
	validation.String("key", "header_name").IsASCII(),

	validation.String("slug", "café").IsLowercase(),
	validation.String("code", "ÉCOLE").IsUppercase(),
	validation.String("title", "こんにちは").IsUTF8(),
)

fmt.Println(err)
// <nil>

Composition

Any · All · Not

Any accepts a value when a rule succeeds; operational errors abort evaluation.

startsA := validation.RuleFunc[string](
	func(value string) error {
		if strings.HasPrefix(value, "A") {
			return nil
		}
		return validation.Invalid(
			"starts_a",
			"Must start with A",
		)
	},
)

endsZ := validation.ContextRuleFunc[string](
	func(_ context.Context, value string) error {
		if strings.HasSuffix(value, "Z") {
			return nil
		}
		return validation.Invalid(
			"ends_z",
			"Must end with Z",
		)
	},
)

allowedCode := validation.All(
	validation.Any[string](startsA, endsZ),
	validation.Not[string](endsZ),
)
err := validation.Validate(
	validation.String("code", "ABC").Using(allowedCode),
)

fmt.Println(err)
// <nil>

err = validation.Validate(
	validation.String("code", "XYZ").
		Using(validation.Any[string](startsA, endsZ)),
)

fmt.Println(err)
// <nil>

Evaluation policy

New · CollectAll · StopOnFirstError · FormatMessages

New creates a validator with first-violation-per-field collection and default messages.

validator := validation.New().
	CollectAll().
	FormatMessages(func(issue validation.Issue) string {
		return issue.Path + ": " + issue.Code
	})

err := validator.Validate(
	validation.String("name", "a").Min(3).Contains("z"),
)

var failures *validation.Errors
if errors.As(err, &failures) {
	fmt.Println(failures.Messages()["name"])
	// [name: min name: contains]
}

first := validator.StopOnFirstError()

err = first.ValidateContext(
	context.Background(),
	validation.String("name", "").Required(),
	validation.Number("age", 0).Min(18),
)

fmt.Println(err)
// name: required

Exact decimals

Decimal · MaxScale

Decimal starts a deferred chain for signed decimal text without exponent notation. Values require ASCII integer digits and may include a fractional part with digits after the point.

err := validation.Validate(
	validation.Decimal("amount", request.Amount).
		Required().
		Min("0.01").
		Max("999999.99").
		MaxScale(2),
	validation.Currency("currency", request.Currency).
		Required().
		USD().
		EUR(),
)

fmt.Println(err)
// <nil>

Currencies

Currency · USD · EUR · GBP

Currency starts a deferred currency allowlist, configured with selectors such as USD and EUR. Select at least one currency before validation; string and defined-string inputs are supported.

err := validation.Validate(
	validation.Currency("currency", request.Currency).
		Required().
		USD().
		EUR().
		GBP(),
)

fmt.Println(err)
// <nil>

See the complete currency selector list.

Currency selectors

Each method adds an accepted currency to the same allowlist.

All 178 currency selectors
Initial Selectors
A .AED() · .AFN() · .ALL() · .AMD() · .AOA() · .ARS() · .AUD() · .AWG() · .AZN()
B .BAM() · .BBD() · .BDT() · .BHD() · .BIF() · .BMD() · .BND() · .BOB() · .BOV() · .BRL() · .BSD() · .BTN() · .BWP() · .BYN() · .BZD()
C .CAD() · .CDF() · .CHE() · .CHF() · .CHW() · .CLF() · .CLP() · .CNY() · .COP() · .COU() · .CRC() · .CUP() · .CVE() · .CZK()
D .DJF() · .DKK() · .DOP() · .DZD()
E .EGP() · .ERN() · .ETB() · .EUR()
F .FJD() · .FKP()
G .GBP() · .GEL() · .GHS() · .GIP() · .GMD() · .GNF() · .GTQ() · .GYD()
H .HKD() · .HNL() · .HTG() · .HUF()
I .IDR() · .ILS() · .INR() · .IQD() · .IRR() · .ISK()
J .JMD() · .JOD() · .JPY()
K .KES() · .KGS() · .KHR() · .KMF() · .KPW() · .KRW() · .KWD() · .KYD() · .KZT()
L .LAK() · .LBP() · .LKR() · .LRD() · .LSL() · .LYD()
M .MAD() · .MDL() · .MGA() · .MKD() · .MMK() · .MNT() · .MOP() · .MRU() · .MUR() · .MVR() · .MWK() · .MXN() · .MXV() · .MYR() · .MZN()
N .NAD() · .NGN() · .NIO() · .NOK() · .NPR() · .NZD()
O .OMR()
P .PAB() · .PEN() · .PGK() · .PHP() · .PKR() · .PLN() · .PYG()
Q .QAR()
R .RON() · .RSD() · .RUB() · .RWF()
S .SAR() · .SBD() · .SCR() · .SDG() · .SEK() · .SGD() · .SHP() · .SLE() · .SOS() · .SRD() · .SSP() · .STN() · .SVC() · .SYP() · .SZL()
T .THB() · .TJS() · .TMT() · .TND() · .TOP() · .TRY() · .TTD() · .TWD() · .TZS()
U .UAH() · .UGX() · .USD() · .USN() · .UYI() · .UYU() · .UYW() · .UZS()
V .VED() · .VES() · .VND() · .VUV()
W .WST()
X .XAD() · .XAF() · .XAG() · .XAU() · .XBA() · .XBB() · .XBC() · .XBD() · .XCD() · .XCG() · .XDR() · .XOF() · .XPD() · .XPF() · .XPT() · .XSU() · .XTS() · .XUA() · .XXX()
Y .YER()
Z .ZAR() · .ZMW() · .ZWG()

Development

make test
make test-race
make vet
make test-coverage
make generate
make check-generated

The root module contains the library and executable examples. The separate docs module contains documentation tooling. See development for checks and validation contracts for API behavior.

The initial release review records the review passes, fixes, and verification evidence.

Documentation

Overview

Package validation provides typed, fluent validation of application values. Rules run only during Validate or ValidateContext. Evaluation collects the first violation per field by default, in declaration order. Validator configures broader collection, global stopping, and message formatting. Unexpected rule errors abort evaluation and remain operational errors rather than client-facing messages.

Builders can be branched and reused without sharing evaluation state. Slices and application dependencies are borrowed; callers must not mutate inputs during evaluation and must coordinate any state used by custom rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(fields ...Field) error

Validate evaluates fields sequentially with a background context.

func ValidateContext

func ValidateContext(ctx context.Context, fields ...Field) error

ValidateContext collects field violations while giving operational errors precedence.

Types

type BoolField

type BoolField[T ~bool] struct {
	// contains filtered or unexported fields
}

BoolField is an immutable fluent chain for bool values.

func Bool

func Bool[T ~bool](path string, value T) BoolField[T]

Bool starts a deferred chain for a borrowed application value.

func (BoolField[T]) Accepted

func (b BoolField[T]) Accepted() BoolField[T]

Accepted requires true while ordinary boolean checks continue to accept false.

func (BoolField[T]) Check

func (b BoolField[T]) Check(check func(context.Context, T) error) BoolField[T]

Check attaches a context-aware application check.

func (BoolField[T]) Equal

func (b BoolField[T]) Equal(other T) BoolField[T]

Equal requires the supplied boolean value.

func (BoolField[T]) Label

func (b BoolField[T]) Label(label string) BoolField[T]

Label sets the human-readable field name without changing its output path.

func (BoolField[T]) Message

func (b BoolField[T]) Message(message string) BoolField[T]

Message overrides the preceding rule message while preserving its code.

func (BoolField[T]) Using

func (b BoolField[T]) Using(rule Rule[T]) BoolField[T]

Using attaches a reusable validator for the exact value type.

type ConfigurationError

type ConfigurationError struct {
	Path    string
	Problem string
}

ConfigurationError identifies a malformed chain or rule rather than invalid input.

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

Error describes the invalid rule configuration without printing submitted values.

type ContextRuleFunc

type ContextRuleFunc[T any] func(context.Context, T) error

ContextRuleFunc adapts a context-aware function into a reusable typed rule.

func (ContextRuleFunc[T]) Validate

func (f ContextRuleFunc[T]) Validate(value T) error

Validate evaluates the rule with a background context.

func (ContextRuleFunc[T]) ValidateContext

func (f ContextRuleFunc[T]) ValidateContext(ctx context.Context, value T) error

ValidateContext forwards the caller's context to the adapted function.

type CurrencyCode added in v0.2.0

type CurrencyCode string

CurrencyCode identifies a currency without attaching precision or monetary behavior. Package constants provide ISO 4217 identifiers; acceptance requires an explicit allowlist.

const (
	// AED identifies the ISO 4217 AED code without prescribing monetary behavior.
	AED CurrencyCode = "AED"
	// AFN identifies the ISO 4217 AFN code without prescribing monetary behavior.
	AFN CurrencyCode = "AFN"
	// ALL identifies the ISO 4217 ALL code without prescribing monetary behavior.
	ALL CurrencyCode = "ALL"
	// AMD identifies the ISO 4217 AMD code without prescribing monetary behavior.
	AMD CurrencyCode = "AMD"
	// AOA identifies the ISO 4217 AOA code without prescribing monetary behavior.
	AOA CurrencyCode = "AOA"
	// ARS identifies the ISO 4217 ARS code without prescribing monetary behavior.
	ARS CurrencyCode = "ARS"
	// AUD identifies the ISO 4217 AUD code without prescribing monetary behavior.
	AUD CurrencyCode = "AUD"
	// AWG identifies the ISO 4217 AWG code without prescribing monetary behavior.
	AWG CurrencyCode = "AWG"
	// AZN identifies the ISO 4217 AZN code without prescribing monetary behavior.
	AZN CurrencyCode = "AZN"
	// BAM identifies the ISO 4217 BAM code without prescribing monetary behavior.
	BAM CurrencyCode = "BAM"
	// BBD identifies the ISO 4217 BBD code without prescribing monetary behavior.
	BBD CurrencyCode = "BBD"
	// BDT identifies the ISO 4217 BDT code without prescribing monetary behavior.
	BDT CurrencyCode = "BDT"
	// BHD identifies the ISO 4217 BHD code without prescribing monetary behavior.
	BHD CurrencyCode = "BHD"
	// BIF identifies the ISO 4217 BIF code without prescribing monetary behavior.
	BIF CurrencyCode = "BIF"
	// BMD identifies the ISO 4217 BMD code without prescribing monetary behavior.
	BMD CurrencyCode = "BMD"
	// BND identifies the ISO 4217 BND code without prescribing monetary behavior.
	BND CurrencyCode = "BND"
	// BOB identifies the ISO 4217 BOB code without prescribing monetary behavior.
	BOB CurrencyCode = "BOB"
	// BOV identifies the ISO 4217 BOV code without prescribing monetary behavior.
	BOV CurrencyCode = "BOV"
	// BRL identifies the ISO 4217 BRL code without prescribing monetary behavior.
	BRL CurrencyCode = "BRL"
	// BSD identifies the ISO 4217 BSD code without prescribing monetary behavior.
	BSD CurrencyCode = "BSD"
	// BTN identifies the ISO 4217 BTN code without prescribing monetary behavior.
	BTN CurrencyCode = "BTN"
	// BWP identifies the ISO 4217 BWP code without prescribing monetary behavior.
	BWP CurrencyCode = "BWP"
	// BYN identifies the ISO 4217 BYN code without prescribing monetary behavior.
	BYN CurrencyCode = "BYN"
	// BZD identifies the ISO 4217 BZD code without prescribing monetary behavior.
	BZD CurrencyCode = "BZD"
	// CAD identifies the ISO 4217 CAD code without prescribing monetary behavior.
	CAD CurrencyCode = "CAD"
	// CDF identifies the ISO 4217 CDF code without prescribing monetary behavior.
	CDF CurrencyCode = "CDF"
	// CHE identifies the ISO 4217 CHE code without prescribing monetary behavior.
	CHE CurrencyCode = "CHE"
	// CHF identifies the ISO 4217 CHF code without prescribing monetary behavior.
	CHF CurrencyCode = "CHF"
	// CHW identifies the ISO 4217 CHW code without prescribing monetary behavior.
	CHW CurrencyCode = "CHW"
	// CLF identifies the ISO 4217 CLF code without prescribing monetary behavior.
	CLF CurrencyCode = "CLF"
	// CLP identifies the ISO 4217 CLP code without prescribing monetary behavior.
	CLP CurrencyCode = "CLP"
	// CNY identifies the ISO 4217 CNY code without prescribing monetary behavior.
	CNY CurrencyCode = "CNY"
	// COP identifies the ISO 4217 COP code without prescribing monetary behavior.
	COP CurrencyCode = "COP"
	// COU identifies the ISO 4217 COU code without prescribing monetary behavior.
	COU CurrencyCode = "COU"
	// CRC identifies the ISO 4217 CRC code without prescribing monetary behavior.
	CRC CurrencyCode = "CRC"
	// CUP identifies the ISO 4217 CUP code without prescribing monetary behavior.
	CUP CurrencyCode = "CUP"
	// CVE identifies the ISO 4217 CVE code without prescribing monetary behavior.
	CVE CurrencyCode = "CVE"
	// CZK identifies the ISO 4217 CZK code without prescribing monetary behavior.
	CZK CurrencyCode = "CZK"
	// DJF identifies the ISO 4217 DJF code without prescribing monetary behavior.
	DJF CurrencyCode = "DJF"
	// DKK identifies the ISO 4217 DKK code without prescribing monetary behavior.
	DKK CurrencyCode = "DKK"
	// DOP identifies the ISO 4217 DOP code without prescribing monetary behavior.
	DOP CurrencyCode = "DOP"
	// DZD identifies the ISO 4217 DZD code without prescribing monetary behavior.
	DZD CurrencyCode = "DZD"
	// EGP identifies the ISO 4217 EGP code without prescribing monetary behavior.
	EGP CurrencyCode = "EGP"
	// ERN identifies the ISO 4217 ERN code without prescribing monetary behavior.
	ERN CurrencyCode = "ERN"
	// ETB identifies the ISO 4217 ETB code without prescribing monetary behavior.
	ETB CurrencyCode = "ETB"
	// EUR identifies the ISO 4217 EUR code without prescribing monetary behavior.
	EUR CurrencyCode = "EUR"
	// FJD identifies the ISO 4217 FJD code without prescribing monetary behavior.
	FJD CurrencyCode = "FJD"
	// FKP identifies the ISO 4217 FKP code without prescribing monetary behavior.
	FKP CurrencyCode = "FKP"
	// GBP identifies the ISO 4217 GBP code without prescribing monetary behavior.
	GBP CurrencyCode = "GBP"
	// GEL identifies the ISO 4217 GEL code without prescribing monetary behavior.
	GEL CurrencyCode = "GEL"
	// GHS identifies the ISO 4217 GHS code without prescribing monetary behavior.
	GHS CurrencyCode = "GHS"
	// GIP identifies the ISO 4217 GIP code without prescribing monetary behavior.
	GIP CurrencyCode = "GIP"
	// GMD identifies the ISO 4217 GMD code without prescribing monetary behavior.
	GMD CurrencyCode = "GMD"
	// GNF identifies the ISO 4217 GNF code without prescribing monetary behavior.
	GNF CurrencyCode = "GNF"
	// GTQ identifies the ISO 4217 GTQ code without prescribing monetary behavior.
	GTQ CurrencyCode = "GTQ"
	// GYD identifies the ISO 4217 GYD code without prescribing monetary behavior.
	GYD CurrencyCode = "GYD"
	// HKD identifies the ISO 4217 HKD code without prescribing monetary behavior.
	HKD CurrencyCode = "HKD"
	// HNL identifies the ISO 4217 HNL code without prescribing monetary behavior.
	HNL CurrencyCode = "HNL"
	// HTG identifies the ISO 4217 HTG code without prescribing monetary behavior.
	HTG CurrencyCode = "HTG"
	// HUF identifies the ISO 4217 HUF code without prescribing monetary behavior.
	HUF CurrencyCode = "HUF"
	// IDR identifies the ISO 4217 IDR code without prescribing monetary behavior.
	IDR CurrencyCode = "IDR"
	// ILS identifies the ISO 4217 ILS code without prescribing monetary behavior.
	ILS CurrencyCode = "ILS"
	// INR identifies the ISO 4217 INR code without prescribing monetary behavior.
	INR CurrencyCode = "INR"
	// IQD identifies the ISO 4217 IQD code without prescribing monetary behavior.
	IQD CurrencyCode = "IQD"
	// IRR identifies the ISO 4217 IRR code without prescribing monetary behavior.
	IRR CurrencyCode = "IRR"
	// ISK identifies the ISO 4217 ISK code without prescribing monetary behavior.
	ISK CurrencyCode = "ISK"
	// JMD identifies the ISO 4217 JMD code without prescribing monetary behavior.
	JMD CurrencyCode = "JMD"
	// JOD identifies the ISO 4217 JOD code without prescribing monetary behavior.
	JOD CurrencyCode = "JOD"
	// JPY identifies the ISO 4217 JPY code without prescribing monetary behavior.
	JPY CurrencyCode = "JPY"
	// KES identifies the ISO 4217 KES code without prescribing monetary behavior.
	KES CurrencyCode = "KES"
	// KGS identifies the ISO 4217 KGS code without prescribing monetary behavior.
	KGS CurrencyCode = "KGS"
	// KHR identifies the ISO 4217 KHR code without prescribing monetary behavior.
	KHR CurrencyCode = "KHR"
	// KMF identifies the ISO 4217 KMF code without prescribing monetary behavior.
	KMF CurrencyCode = "KMF"
	// KPW identifies the ISO 4217 KPW code without prescribing monetary behavior.
	KPW CurrencyCode = "KPW"
	// KRW identifies the ISO 4217 KRW code without prescribing monetary behavior.
	KRW CurrencyCode = "KRW"
	// KWD identifies the ISO 4217 KWD code without prescribing monetary behavior.
	KWD CurrencyCode = "KWD"
	// KYD identifies the ISO 4217 KYD code without prescribing monetary behavior.
	KYD CurrencyCode = "KYD"
	// KZT identifies the ISO 4217 KZT code without prescribing monetary behavior.
	KZT CurrencyCode = "KZT"
	// LAK identifies the ISO 4217 LAK code without prescribing monetary behavior.
	LAK CurrencyCode = "LAK"
	// LBP identifies the ISO 4217 LBP code without prescribing monetary behavior.
	LBP CurrencyCode = "LBP"
	// LKR identifies the ISO 4217 LKR code without prescribing monetary behavior.
	LKR CurrencyCode = "LKR"
	// LRD identifies the ISO 4217 LRD code without prescribing monetary behavior.
	LRD CurrencyCode = "LRD"
	// LSL identifies the ISO 4217 LSL code without prescribing monetary behavior.
	LSL CurrencyCode = "LSL"
	// LYD identifies the ISO 4217 LYD code without prescribing monetary behavior.
	LYD CurrencyCode = "LYD"
	// MAD identifies the ISO 4217 MAD code without prescribing monetary behavior.
	MAD CurrencyCode = "MAD"
	// MDL identifies the ISO 4217 MDL code without prescribing monetary behavior.
	MDL CurrencyCode = "MDL"
	// MGA identifies the ISO 4217 MGA code without prescribing monetary behavior.
	MGA CurrencyCode = "MGA"
	// MKD identifies the ISO 4217 MKD code without prescribing monetary behavior.
	MKD CurrencyCode = "MKD"
	// MMK identifies the ISO 4217 MMK code without prescribing monetary behavior.
	MMK CurrencyCode = "MMK"
	// MNT identifies the ISO 4217 MNT code without prescribing monetary behavior.
	MNT CurrencyCode = "MNT"
	// MOP identifies the ISO 4217 MOP code without prescribing monetary behavior.
	MOP CurrencyCode = "MOP"
	// MRU identifies the ISO 4217 MRU code without prescribing monetary behavior.
	MRU CurrencyCode = "MRU"
	// MUR identifies the ISO 4217 MUR code without prescribing monetary behavior.
	MUR CurrencyCode = "MUR"
	// MVR identifies the ISO 4217 MVR code without prescribing monetary behavior.
	MVR CurrencyCode = "MVR"
	// MWK identifies the ISO 4217 MWK code without prescribing monetary behavior.
	MWK CurrencyCode = "MWK"
	// MXN identifies the ISO 4217 MXN code without prescribing monetary behavior.
	MXN CurrencyCode = "MXN"
	// MXV identifies the ISO 4217 MXV code without prescribing monetary behavior.
	MXV CurrencyCode = "MXV"
	// MYR identifies the ISO 4217 MYR code without prescribing monetary behavior.
	MYR CurrencyCode = "MYR"
	// MZN identifies the ISO 4217 MZN code without prescribing monetary behavior.
	MZN CurrencyCode = "MZN"
	// NAD identifies the ISO 4217 NAD code without prescribing monetary behavior.
	NAD CurrencyCode = "NAD"
	// NGN identifies the ISO 4217 NGN code without prescribing monetary behavior.
	NGN CurrencyCode = "NGN"
	// NIO identifies the ISO 4217 NIO code without prescribing monetary behavior.
	NIO CurrencyCode = "NIO"
	// NOK identifies the ISO 4217 NOK code without prescribing monetary behavior.
	NOK CurrencyCode = "NOK"
	// NPR identifies the ISO 4217 NPR code without prescribing monetary behavior.
	NPR CurrencyCode = "NPR"
	// NZD identifies the ISO 4217 NZD code without prescribing monetary behavior.
	NZD CurrencyCode = "NZD"
	// OMR identifies the ISO 4217 OMR code without prescribing monetary behavior.
	OMR CurrencyCode = "OMR"
	// PAB identifies the ISO 4217 PAB code without prescribing monetary behavior.
	PAB CurrencyCode = "PAB"
	// PEN identifies the ISO 4217 PEN code without prescribing monetary behavior.
	PEN CurrencyCode = "PEN"
	// PGK identifies the ISO 4217 PGK code without prescribing monetary behavior.
	PGK CurrencyCode = "PGK"
	// PHP identifies the ISO 4217 PHP code without prescribing monetary behavior.
	PHP CurrencyCode = "PHP"
	// PKR identifies the ISO 4217 PKR code without prescribing monetary behavior.
	PKR CurrencyCode = "PKR"
	// PLN identifies the ISO 4217 PLN code without prescribing monetary behavior.
	PLN CurrencyCode = "PLN"
	// PYG identifies the ISO 4217 PYG code without prescribing monetary behavior.
	PYG CurrencyCode = "PYG"
	// QAR identifies the ISO 4217 QAR code without prescribing monetary behavior.
	QAR CurrencyCode = "QAR"
	// RON identifies the ISO 4217 RON code without prescribing monetary behavior.
	RON CurrencyCode = "RON"
	// RSD identifies the ISO 4217 RSD code without prescribing monetary behavior.
	RSD CurrencyCode = "RSD"
	// RUB identifies the ISO 4217 RUB code without prescribing monetary behavior.
	RUB CurrencyCode = "RUB"
	// RWF identifies the ISO 4217 RWF code without prescribing monetary behavior.
	RWF CurrencyCode = "RWF"
	// SAR identifies the ISO 4217 SAR code without prescribing monetary behavior.
	SAR CurrencyCode = "SAR"
	// SBD identifies the ISO 4217 SBD code without prescribing monetary behavior.
	SBD CurrencyCode = "SBD"
	// SCR identifies the ISO 4217 SCR code without prescribing monetary behavior.
	SCR CurrencyCode = "SCR"
	// SDG identifies the ISO 4217 SDG code without prescribing monetary behavior.
	SDG CurrencyCode = "SDG"
	// SEK identifies the ISO 4217 SEK code without prescribing monetary behavior.
	SEK CurrencyCode = "SEK"
	// SGD identifies the ISO 4217 SGD code without prescribing monetary behavior.
	SGD CurrencyCode = "SGD"
	// SHP identifies the ISO 4217 SHP code without prescribing monetary behavior.
	SHP CurrencyCode = "SHP"
	// SLE identifies the ISO 4217 SLE code without prescribing monetary behavior.
	SLE CurrencyCode = "SLE"
	// SOS identifies the ISO 4217 SOS code without prescribing monetary behavior.
	SOS CurrencyCode = "SOS"
	// SRD identifies the ISO 4217 SRD code without prescribing monetary behavior.
	SRD CurrencyCode = "SRD"
	// SSP identifies the ISO 4217 SSP code without prescribing monetary behavior.
	SSP CurrencyCode = "SSP"
	// STN identifies the ISO 4217 STN code without prescribing monetary behavior.
	STN CurrencyCode = "STN"
	// SVC identifies the ISO 4217 SVC code without prescribing monetary behavior.
	SVC CurrencyCode = "SVC"
	// SYP identifies the ISO 4217 SYP code without prescribing monetary behavior.
	SYP CurrencyCode = "SYP"
	// SZL identifies the ISO 4217 SZL code without prescribing monetary behavior.
	SZL CurrencyCode = "SZL"
	// THB identifies the ISO 4217 THB code without prescribing monetary behavior.
	THB CurrencyCode = "THB"
	// TJS identifies the ISO 4217 TJS code without prescribing monetary behavior.
	TJS CurrencyCode = "TJS"
	// TMT identifies the ISO 4217 TMT code without prescribing monetary behavior.
	TMT CurrencyCode = "TMT"
	// TND identifies the ISO 4217 TND code without prescribing monetary behavior.
	TND CurrencyCode = "TND"
	// TOP identifies the ISO 4217 TOP code without prescribing monetary behavior.
	TOP CurrencyCode = "TOP"
	// TRY identifies the ISO 4217 TRY code without prescribing monetary behavior.
	TRY CurrencyCode = "TRY"
	// TTD identifies the ISO 4217 TTD code without prescribing monetary behavior.
	TTD CurrencyCode = "TTD"
	// TWD identifies the ISO 4217 TWD code without prescribing monetary behavior.
	TWD CurrencyCode = "TWD"
	// TZS identifies the ISO 4217 TZS code without prescribing monetary behavior.
	TZS CurrencyCode = "TZS"
	// UAH identifies the ISO 4217 UAH code without prescribing monetary behavior.
	UAH CurrencyCode = "UAH"
	// UGX identifies the ISO 4217 UGX code without prescribing monetary behavior.
	UGX CurrencyCode = "UGX"
	// USD identifies the ISO 4217 USD code without prescribing monetary behavior.
	USD CurrencyCode = "USD"
	// USN identifies the ISO 4217 USN code without prescribing monetary behavior.
	USN CurrencyCode = "USN"
	// UYI identifies the ISO 4217 UYI code without prescribing monetary behavior.
	UYI CurrencyCode = "UYI"
	// UYU identifies the ISO 4217 UYU code without prescribing monetary behavior.
	UYU CurrencyCode = "UYU"
	// UYW identifies the ISO 4217 UYW code without prescribing monetary behavior.
	UYW CurrencyCode = "UYW"
	// UZS identifies the ISO 4217 UZS code without prescribing monetary behavior.
	UZS CurrencyCode = "UZS"
	// VED identifies the ISO 4217 VED code without prescribing monetary behavior.
	VED CurrencyCode = "VED"
	// VES identifies the ISO 4217 VES code without prescribing monetary behavior.
	VES CurrencyCode = "VES"
	// VND identifies the ISO 4217 VND code without prescribing monetary behavior.
	VND CurrencyCode = "VND"
	// VUV identifies the ISO 4217 VUV code without prescribing monetary behavior.
	VUV CurrencyCode = "VUV"
	// WST identifies the ISO 4217 WST code without prescribing monetary behavior.
	WST CurrencyCode = "WST"
	// XAD identifies the ISO 4217 XAD code without prescribing monetary behavior.
	XAD CurrencyCode = "XAD"
	// XAF identifies the ISO 4217 XAF code without prescribing monetary behavior.
	XAF CurrencyCode = "XAF"
	// XAG identifies the ISO 4217 XAG code without prescribing monetary behavior.
	XAG CurrencyCode = "XAG"
	// XAU identifies the ISO 4217 XAU code without prescribing monetary behavior.
	XAU CurrencyCode = "XAU"
	// XBA identifies the ISO 4217 XBA code without prescribing monetary behavior.
	XBA CurrencyCode = "XBA"
	// XBB identifies the ISO 4217 XBB code without prescribing monetary behavior.
	XBB CurrencyCode = "XBB"
	// XBC identifies the ISO 4217 XBC code without prescribing monetary behavior.
	XBC CurrencyCode = "XBC"
	// XBD identifies the ISO 4217 XBD code without prescribing monetary behavior.
	XBD CurrencyCode = "XBD"
	// XCD identifies the ISO 4217 XCD code without prescribing monetary behavior.
	XCD CurrencyCode = "XCD"
	// XCG identifies the ISO 4217 XCG code without prescribing monetary behavior.
	XCG CurrencyCode = "XCG"
	// XDR identifies the ISO 4217 XDR code without prescribing monetary behavior.
	XDR CurrencyCode = "XDR"
	// XOF identifies the ISO 4217 XOF code without prescribing monetary behavior.
	XOF CurrencyCode = "XOF"
	// XPD identifies the ISO 4217 XPD code without prescribing monetary behavior.
	XPD CurrencyCode = "XPD"
	// XPF identifies the ISO 4217 XPF code without prescribing monetary behavior.
	XPF CurrencyCode = "XPF"
	// XPT identifies the ISO 4217 XPT code without prescribing monetary behavior.
	XPT CurrencyCode = "XPT"
	// XSU identifies the ISO 4217 XSU code without prescribing monetary behavior.
	XSU CurrencyCode = "XSU"
	// XTS identifies the ISO 4217 XTS code without prescribing monetary behavior.
	XTS CurrencyCode = "XTS"
	// XUA identifies the ISO 4217 XUA code without prescribing monetary behavior.
	XUA CurrencyCode = "XUA"
	// XXX identifies the ISO 4217 XXX code without prescribing monetary behavior.
	XXX CurrencyCode = "XXX"
	// YER identifies the ISO 4217 YER code without prescribing monetary behavior.
	YER CurrencyCode = "YER"
	// ZAR identifies the ISO 4217 ZAR code without prescribing monetary behavior.
	ZAR CurrencyCode = "ZAR"
	// ZMW identifies the ISO 4217 ZMW code without prescribing monetary behavior.
	ZMW CurrencyCode = "ZMW"
	// ZWG identifies the ISO 4217 ZWG code without prescribing monetary behavior.
	ZWG CurrencyCode = "ZWG"
)

type CurrencyField added in v0.2.0

type CurrencyField[T ~string] struct {
	// contains filtered or unexported fields
}

CurrencyField is an immutable fluent chain with one shared currency allowlist.

func Currency added in v0.2.0

func Currency[T ~string](path string, value T) CurrencyField[T]

Currency starts a deferred currency allowlist, configured with selectors such as USD and EUR. Select at least one currency before validation; string and defined-string inputs are supported.

func (CurrencyField[T]) AED added in v0.2.0

func (b CurrencyField[T]) AED() CurrencyField[T]

AED adds AED to the field's shared currency allowlist.

func (CurrencyField[T]) AFN added in v0.2.0

func (b CurrencyField[T]) AFN() CurrencyField[T]

AFN adds AFN to the field's shared currency allowlist.

func (CurrencyField[T]) ALL added in v0.2.0

func (b CurrencyField[T]) ALL() CurrencyField[T]

ALL adds ALL to the field's shared currency allowlist.

func (CurrencyField[T]) AMD added in v0.2.0

func (b CurrencyField[T]) AMD() CurrencyField[T]

AMD adds AMD to the field's shared currency allowlist.

func (CurrencyField[T]) AOA added in v0.2.0

func (b CurrencyField[T]) AOA() CurrencyField[T]

AOA adds AOA to the field's shared currency allowlist.

func (CurrencyField[T]) ARS added in v0.2.0

func (b CurrencyField[T]) ARS() CurrencyField[T]

ARS adds ARS to the field's shared currency allowlist.

func (CurrencyField[T]) AUD added in v0.2.0

func (b CurrencyField[T]) AUD() CurrencyField[T]

AUD adds AUD to the field's shared currency allowlist.

func (CurrencyField[T]) AWG added in v0.2.0

func (b CurrencyField[T]) AWG() CurrencyField[T]

AWG adds AWG to the field's shared currency allowlist.

func (CurrencyField[T]) AZN added in v0.2.0

func (b CurrencyField[T]) AZN() CurrencyField[T]

AZN adds AZN to the field's shared currency allowlist.

func (CurrencyField[T]) BAM added in v0.2.0

func (b CurrencyField[T]) BAM() CurrencyField[T]

BAM adds BAM to the field's shared currency allowlist.

func (CurrencyField[T]) BBD added in v0.2.0

func (b CurrencyField[T]) BBD() CurrencyField[T]

BBD adds BBD to the field's shared currency allowlist.

func (CurrencyField[T]) BDT added in v0.2.0

func (b CurrencyField[T]) BDT() CurrencyField[T]

BDT adds BDT to the field's shared currency allowlist.

func (CurrencyField[T]) BHD added in v0.2.0

func (b CurrencyField[T]) BHD() CurrencyField[T]

BHD adds BHD to the field's shared currency allowlist.

func (CurrencyField[T]) BIF added in v0.2.0

func (b CurrencyField[T]) BIF() CurrencyField[T]

BIF adds BIF to the field's shared currency allowlist.

func (CurrencyField[T]) BMD added in v0.2.0

func (b CurrencyField[T]) BMD() CurrencyField[T]

BMD adds BMD to the field's shared currency allowlist.

func (CurrencyField[T]) BND added in v0.2.0

func (b CurrencyField[T]) BND() CurrencyField[T]

BND adds BND to the field's shared currency allowlist.

func (CurrencyField[T]) BOB added in v0.2.0

func (b CurrencyField[T]) BOB() CurrencyField[T]

BOB adds BOB to the field's shared currency allowlist.

func (CurrencyField[T]) BOV added in v0.2.0

func (b CurrencyField[T]) BOV() CurrencyField[T]

BOV adds BOV to the field's shared currency allowlist.

func (CurrencyField[T]) BRL added in v0.2.0

func (b CurrencyField[T]) BRL() CurrencyField[T]

BRL adds BRL to the field's shared currency allowlist.

func (CurrencyField[T]) BSD added in v0.2.0

func (b CurrencyField[T]) BSD() CurrencyField[T]

BSD adds BSD to the field's shared currency allowlist.

func (CurrencyField[T]) BTN added in v0.2.0

func (b CurrencyField[T]) BTN() CurrencyField[T]

BTN adds BTN to the field's shared currency allowlist.

func (CurrencyField[T]) BWP added in v0.2.0

func (b CurrencyField[T]) BWP() CurrencyField[T]

BWP adds BWP to the field's shared currency allowlist.

func (CurrencyField[T]) BYN added in v0.2.0

func (b CurrencyField[T]) BYN() CurrencyField[T]

BYN adds BYN to the field's shared currency allowlist.

func (CurrencyField[T]) BZD added in v0.2.0

func (b CurrencyField[T]) BZD() CurrencyField[T]

BZD adds BZD to the field's shared currency allowlist.

func (CurrencyField[T]) CAD added in v0.2.0

func (b CurrencyField[T]) CAD() CurrencyField[T]

CAD adds CAD to the field's shared currency allowlist.

func (CurrencyField[T]) CDF added in v0.2.0

func (b CurrencyField[T]) CDF() CurrencyField[T]

CDF adds CDF to the field's shared currency allowlist.

func (CurrencyField[T]) CHE added in v0.2.0

func (b CurrencyField[T]) CHE() CurrencyField[T]

CHE adds CHE to the field's shared currency allowlist.

func (CurrencyField[T]) CHF added in v0.2.0

func (b CurrencyField[T]) CHF() CurrencyField[T]

CHF adds CHF to the field's shared currency allowlist.

func (CurrencyField[T]) CHW added in v0.2.0

func (b CurrencyField[T]) CHW() CurrencyField[T]

CHW adds CHW to the field's shared currency allowlist.

func (CurrencyField[T]) CLF added in v0.2.0

func (b CurrencyField[T]) CLF() CurrencyField[T]

CLF adds CLF to the field's shared currency allowlist.

func (CurrencyField[T]) CLP added in v0.2.0

func (b CurrencyField[T]) CLP() CurrencyField[T]

CLP adds CLP to the field's shared currency allowlist.

func (CurrencyField[T]) CNY added in v0.2.0

func (b CurrencyField[T]) CNY() CurrencyField[T]

CNY adds CNY to the field's shared currency allowlist.

func (CurrencyField[T]) COP added in v0.2.0

func (b CurrencyField[T]) COP() CurrencyField[T]

COP adds COP to the field's shared currency allowlist.

func (CurrencyField[T]) COU added in v0.2.0

func (b CurrencyField[T]) COU() CurrencyField[T]

COU adds COU to the field's shared currency allowlist.

func (CurrencyField[T]) CRC added in v0.2.0

func (b CurrencyField[T]) CRC() CurrencyField[T]

CRC adds CRC to the field's shared currency allowlist.

func (CurrencyField[T]) CUP added in v0.2.0

func (b CurrencyField[T]) CUP() CurrencyField[T]

CUP adds CUP to the field's shared currency allowlist.

func (CurrencyField[T]) CVE added in v0.2.0

func (b CurrencyField[T]) CVE() CurrencyField[T]

CVE adds CVE to the field's shared currency allowlist.

func (CurrencyField[T]) CZK added in v0.2.0

func (b CurrencyField[T]) CZK() CurrencyField[T]

CZK adds CZK to the field's shared currency allowlist.

func (CurrencyField[T]) Check added in v0.2.0

func (b CurrencyField[T]) Check(check func(context.Context, T) error) CurrencyField[T]

Check attaches a context-aware application check after the currency allowlist.

func (CurrencyField[T]) DJF added in v0.2.0

func (b CurrencyField[T]) DJF() CurrencyField[T]

DJF adds DJF to the field's shared currency allowlist.

func (CurrencyField[T]) DKK added in v0.2.0

func (b CurrencyField[T]) DKK() CurrencyField[T]

DKK adds DKK to the field's shared currency allowlist.

func (CurrencyField[T]) DOP added in v0.2.0

func (b CurrencyField[T]) DOP() CurrencyField[T]

DOP adds DOP to the field's shared currency allowlist.

func (CurrencyField[T]) DZD added in v0.2.0

func (b CurrencyField[T]) DZD() CurrencyField[T]

DZD adds DZD to the field's shared currency allowlist.

func (CurrencyField[T]) EGP added in v0.2.0

func (b CurrencyField[T]) EGP() CurrencyField[T]

EGP adds EGP to the field's shared currency allowlist.

func (CurrencyField[T]) ERN added in v0.2.0

func (b CurrencyField[T]) ERN() CurrencyField[T]

ERN adds ERN to the field's shared currency allowlist.

func (CurrencyField[T]) ETB added in v0.2.0

func (b CurrencyField[T]) ETB() CurrencyField[T]

ETB adds ETB to the field's shared currency allowlist.

func (CurrencyField[T]) EUR added in v0.2.0

func (b CurrencyField[T]) EUR() CurrencyField[T]

EUR adds EUR to the field's shared currency allowlist.

func (CurrencyField[T]) FJD added in v0.2.0

func (b CurrencyField[T]) FJD() CurrencyField[T]

FJD adds FJD to the field's shared currency allowlist.

func (CurrencyField[T]) FKP added in v0.2.0

func (b CurrencyField[T]) FKP() CurrencyField[T]

FKP adds FKP to the field's shared currency allowlist.

func (CurrencyField[T]) GBP added in v0.2.0

func (b CurrencyField[T]) GBP() CurrencyField[T]

GBP adds GBP to the field's shared currency allowlist.

func (CurrencyField[T]) GEL added in v0.2.0

func (b CurrencyField[T]) GEL() CurrencyField[T]

GEL adds GEL to the field's shared currency allowlist.

func (CurrencyField[T]) GHS added in v0.2.0

func (b CurrencyField[T]) GHS() CurrencyField[T]

GHS adds GHS to the field's shared currency allowlist.

func (CurrencyField[T]) GIP added in v0.2.0

func (b CurrencyField[T]) GIP() CurrencyField[T]

GIP adds GIP to the field's shared currency allowlist.

func (CurrencyField[T]) GMD added in v0.2.0

func (b CurrencyField[T]) GMD() CurrencyField[T]

GMD adds GMD to the field's shared currency allowlist.

func (CurrencyField[T]) GNF added in v0.2.0

func (b CurrencyField[T]) GNF() CurrencyField[T]

GNF adds GNF to the field's shared currency allowlist.

func (CurrencyField[T]) GTQ added in v0.2.0

func (b CurrencyField[T]) GTQ() CurrencyField[T]

GTQ adds GTQ to the field's shared currency allowlist.

func (CurrencyField[T]) GYD added in v0.2.0

func (b CurrencyField[T]) GYD() CurrencyField[T]

GYD adds GYD to the field's shared currency allowlist.

func (CurrencyField[T]) HKD added in v0.2.0

func (b CurrencyField[T]) HKD() CurrencyField[T]

HKD adds HKD to the field's shared currency allowlist.

func (CurrencyField[T]) HNL added in v0.2.0

func (b CurrencyField[T]) HNL() CurrencyField[T]

HNL adds HNL to the field's shared currency allowlist.

func (CurrencyField[T]) HTG added in v0.2.0

func (b CurrencyField[T]) HTG() CurrencyField[T]

HTG adds HTG to the field's shared currency allowlist.

func (CurrencyField[T]) HUF added in v0.2.0

func (b CurrencyField[T]) HUF() CurrencyField[T]

HUF adds HUF to the field's shared currency allowlist.

func (CurrencyField[T]) IDR added in v0.2.0

func (b CurrencyField[T]) IDR() CurrencyField[T]

IDR adds IDR to the field's shared currency allowlist.

func (CurrencyField[T]) ILS added in v0.2.0

func (b CurrencyField[T]) ILS() CurrencyField[T]

ILS adds ILS to the field's shared currency allowlist.

func (CurrencyField[T]) INR added in v0.2.0

func (b CurrencyField[T]) INR() CurrencyField[T]

INR adds INR to the field's shared currency allowlist.

func (CurrencyField[T]) IQD added in v0.2.0

func (b CurrencyField[T]) IQD() CurrencyField[T]

IQD adds IQD to the field's shared currency allowlist.

func (CurrencyField[T]) IRR added in v0.2.0

func (b CurrencyField[T]) IRR() CurrencyField[T]

IRR adds IRR to the field's shared currency allowlist.

func (CurrencyField[T]) ISK added in v0.2.0

func (b CurrencyField[T]) ISK() CurrencyField[T]

ISK adds ISK to the field's shared currency allowlist.

func (CurrencyField[T]) JMD added in v0.2.0

func (b CurrencyField[T]) JMD() CurrencyField[T]

JMD adds JMD to the field's shared currency allowlist.

func (CurrencyField[T]) JOD added in v0.2.0

func (b CurrencyField[T]) JOD() CurrencyField[T]

JOD adds JOD to the field's shared currency allowlist.

func (CurrencyField[T]) JPY added in v0.2.0

func (b CurrencyField[T]) JPY() CurrencyField[T]

JPY adds JPY to the field's shared currency allowlist.

func (CurrencyField[T]) KES added in v0.2.0

func (b CurrencyField[T]) KES() CurrencyField[T]

KES adds KES to the field's shared currency allowlist.

func (CurrencyField[T]) KGS added in v0.2.0

func (b CurrencyField[T]) KGS() CurrencyField[T]

KGS adds KGS to the field's shared currency allowlist.

func (CurrencyField[T]) KHR added in v0.2.0

func (b CurrencyField[T]) KHR() CurrencyField[T]

KHR adds KHR to the field's shared currency allowlist.

func (CurrencyField[T]) KMF added in v0.2.0

func (b CurrencyField[T]) KMF() CurrencyField[T]

KMF adds KMF to the field's shared currency allowlist.

func (CurrencyField[T]) KPW added in v0.2.0

func (b CurrencyField[T]) KPW() CurrencyField[T]

KPW adds KPW to the field's shared currency allowlist.

func (CurrencyField[T]) KRW added in v0.2.0

func (b CurrencyField[T]) KRW() CurrencyField[T]

KRW adds KRW to the field's shared currency allowlist.

func (CurrencyField[T]) KWD added in v0.2.0

func (b CurrencyField[T]) KWD() CurrencyField[T]

KWD adds KWD to the field's shared currency allowlist.

func (CurrencyField[T]) KYD added in v0.2.0

func (b CurrencyField[T]) KYD() CurrencyField[T]

KYD adds KYD to the field's shared currency allowlist.

func (CurrencyField[T]) KZT added in v0.2.0

func (b CurrencyField[T]) KZT() CurrencyField[T]

KZT adds KZT to the field's shared currency allowlist.

func (CurrencyField[T]) LAK added in v0.2.0

func (b CurrencyField[T]) LAK() CurrencyField[T]

LAK adds LAK to the field's shared currency allowlist.

func (CurrencyField[T]) LBP added in v0.2.0

func (b CurrencyField[T]) LBP() CurrencyField[T]

LBP adds LBP to the field's shared currency allowlist.

func (CurrencyField[T]) LKR added in v0.2.0

func (b CurrencyField[T]) LKR() CurrencyField[T]

LKR adds LKR to the field's shared currency allowlist.

func (CurrencyField[T]) LRD added in v0.2.0

func (b CurrencyField[T]) LRD() CurrencyField[T]

LRD adds LRD to the field's shared currency allowlist.

func (CurrencyField[T]) LSL added in v0.2.0

func (b CurrencyField[T]) LSL() CurrencyField[T]

LSL adds LSL to the field's shared currency allowlist.

func (CurrencyField[T]) LYD added in v0.2.0

func (b CurrencyField[T]) LYD() CurrencyField[T]

LYD adds LYD to the field's shared currency allowlist.

func (CurrencyField[T]) Label added in v0.2.0

func (b CurrencyField[T]) Label(label string) CurrencyField[T]

Label changes human-readable prose without changing the currency field path.

func (CurrencyField[T]) MAD added in v0.2.0

func (b CurrencyField[T]) MAD() CurrencyField[T]

MAD adds MAD to the field's shared currency allowlist.

func (CurrencyField[T]) MDL added in v0.2.0

func (b CurrencyField[T]) MDL() CurrencyField[T]

MDL adds MDL to the field's shared currency allowlist.

func (CurrencyField[T]) MGA added in v0.2.0

func (b CurrencyField[T]) MGA() CurrencyField[T]

MGA adds MGA to the field's shared currency allowlist.

func (CurrencyField[T]) MKD added in v0.2.0

func (b CurrencyField[T]) MKD() CurrencyField[T]

MKD adds MKD to the field's shared currency allowlist.

func (CurrencyField[T]) MMK added in v0.2.0

func (b CurrencyField[T]) MMK() CurrencyField[T]

MMK adds MMK to the field's shared currency allowlist.

func (CurrencyField[T]) MNT added in v0.2.0

func (b CurrencyField[T]) MNT() CurrencyField[T]

MNT adds MNT to the field's shared currency allowlist.

func (CurrencyField[T]) MOP added in v0.2.0

func (b CurrencyField[T]) MOP() CurrencyField[T]

MOP adds MOP to the field's shared currency allowlist.

func (CurrencyField[T]) MRU added in v0.2.0

func (b CurrencyField[T]) MRU() CurrencyField[T]

MRU adds MRU to the field's shared currency allowlist.

func (CurrencyField[T]) MUR added in v0.2.0

func (b CurrencyField[T]) MUR() CurrencyField[T]

MUR adds MUR to the field's shared currency allowlist.

func (CurrencyField[T]) MVR added in v0.2.0

func (b CurrencyField[T]) MVR() CurrencyField[T]

MVR adds MVR to the field's shared currency allowlist.

func (CurrencyField[T]) MWK added in v0.2.0

func (b CurrencyField[T]) MWK() CurrencyField[T]

MWK adds MWK to the field's shared currency allowlist.

func (CurrencyField[T]) MXN added in v0.2.0

func (b CurrencyField[T]) MXN() CurrencyField[T]

MXN adds MXN to the field's shared currency allowlist.

func (CurrencyField[T]) MXV added in v0.2.0

func (b CurrencyField[T]) MXV() CurrencyField[T]

MXV adds MXV to the field's shared currency allowlist.

func (CurrencyField[T]) MYR added in v0.2.0

func (b CurrencyField[T]) MYR() CurrencyField[T]

MYR adds MYR to the field's shared currency allowlist.

func (CurrencyField[T]) MZN added in v0.2.0

func (b CurrencyField[T]) MZN() CurrencyField[T]

MZN adds MZN to the field's shared currency allowlist.

func (CurrencyField[T]) Message added in v0.2.0

func (b CurrencyField[T]) Message(message string) CurrencyField[T]

Message overrides the preceding rule message while preserving its code.

func (CurrencyField[T]) NAD added in v0.2.0

func (b CurrencyField[T]) NAD() CurrencyField[T]

NAD adds NAD to the field's shared currency allowlist.

func (CurrencyField[T]) NGN added in v0.2.0

func (b CurrencyField[T]) NGN() CurrencyField[T]

NGN adds NGN to the field's shared currency allowlist.

func (CurrencyField[T]) NIO added in v0.2.0

func (b CurrencyField[T]) NIO() CurrencyField[T]

NIO adds NIO to the field's shared currency allowlist.

func (CurrencyField[T]) NOK added in v0.2.0

func (b CurrencyField[T]) NOK() CurrencyField[T]

NOK adds NOK to the field's shared currency allowlist.

func (CurrencyField[T]) NPR added in v0.2.0

func (b CurrencyField[T]) NPR() CurrencyField[T]

NPR adds NPR to the field's shared currency allowlist.

func (CurrencyField[T]) NZD added in v0.2.0

func (b CurrencyField[T]) NZD() CurrencyField[T]

NZD adds NZD to the field's shared currency allowlist.

func (CurrencyField[T]) OMR added in v0.2.0

func (b CurrencyField[T]) OMR() CurrencyField[T]

OMR adds OMR to the field's shared currency allowlist.

func (CurrencyField[T]) PAB added in v0.2.0

func (b CurrencyField[T]) PAB() CurrencyField[T]

PAB adds PAB to the field's shared currency allowlist.

func (CurrencyField[T]) PEN added in v0.2.0

func (b CurrencyField[T]) PEN() CurrencyField[T]

PEN adds PEN to the field's shared currency allowlist.

func (CurrencyField[T]) PGK added in v0.2.0

func (b CurrencyField[T]) PGK() CurrencyField[T]

PGK adds PGK to the field's shared currency allowlist.

func (CurrencyField[T]) PHP added in v0.2.0

func (b CurrencyField[T]) PHP() CurrencyField[T]

PHP adds PHP to the field's shared currency allowlist.

func (CurrencyField[T]) PKR added in v0.2.0

func (b CurrencyField[T]) PKR() CurrencyField[T]

PKR adds PKR to the field's shared currency allowlist.

func (CurrencyField[T]) PLN added in v0.2.0

func (b CurrencyField[T]) PLN() CurrencyField[T]

PLN adds PLN to the field's shared currency allowlist.

func (CurrencyField[T]) PYG added in v0.2.0

func (b CurrencyField[T]) PYG() CurrencyField[T]

PYG adds PYG to the field's shared currency allowlist.

func (CurrencyField[T]) QAR added in v0.2.0

func (b CurrencyField[T]) QAR() CurrencyField[T]

QAR adds QAR to the field's shared currency allowlist.

func (CurrencyField[T]) RON added in v0.2.0

func (b CurrencyField[T]) RON() CurrencyField[T]

RON adds RON to the field's shared currency allowlist.

func (CurrencyField[T]) RSD added in v0.2.0

func (b CurrencyField[T]) RSD() CurrencyField[T]

RSD adds RSD to the field's shared currency allowlist.

func (CurrencyField[T]) RUB added in v0.2.0

func (b CurrencyField[T]) RUB() CurrencyField[T]

RUB adds RUB to the field's shared currency allowlist.

func (CurrencyField[T]) RWF added in v0.2.0

func (b CurrencyField[T]) RWF() CurrencyField[T]

RWF adds RWF to the field's shared currency allowlist.

func (CurrencyField[T]) Required added in v0.2.0

func (b CurrencyField[T]) Required() CurrencyField[T]

Required rejects an empty currency code before allowlist and application checks.

func (CurrencyField[T]) RequiredIf added in v0.2.0

func (b CurrencyField[T]) RequiredIf(condition bool) CurrencyField[T]

RequiredIf rejects an empty code when condition is true; the allowlist still applies.

func (CurrencyField[T]) SAR added in v0.2.0

func (b CurrencyField[T]) SAR() CurrencyField[T]

SAR adds SAR to the field's shared currency allowlist.

func (CurrencyField[T]) SBD added in v0.2.0

func (b CurrencyField[T]) SBD() CurrencyField[T]

SBD adds SBD to the field's shared currency allowlist.

func (CurrencyField[T]) SCR added in v0.2.0

func (b CurrencyField[T]) SCR() CurrencyField[T]

SCR adds SCR to the field's shared currency allowlist.

func (CurrencyField[T]) SDG added in v0.2.0

func (b CurrencyField[T]) SDG() CurrencyField[T]

SDG adds SDG to the field's shared currency allowlist.

func (CurrencyField[T]) SEK added in v0.2.0

func (b CurrencyField[T]) SEK() CurrencyField[T]

SEK adds SEK to the field's shared currency allowlist.

func (CurrencyField[T]) SGD added in v0.2.0

func (b CurrencyField[T]) SGD() CurrencyField[T]

SGD adds SGD to the field's shared currency allowlist.

func (CurrencyField[T]) SHP added in v0.2.0

func (b CurrencyField[T]) SHP() CurrencyField[T]

SHP adds SHP to the field's shared currency allowlist.

func (CurrencyField[T]) SLE added in v0.2.0

func (b CurrencyField[T]) SLE() CurrencyField[T]

SLE adds SLE to the field's shared currency allowlist.

func (CurrencyField[T]) SOS added in v0.2.0

func (b CurrencyField[T]) SOS() CurrencyField[T]

SOS adds SOS to the field's shared currency allowlist.

func (CurrencyField[T]) SRD added in v0.2.0

func (b CurrencyField[T]) SRD() CurrencyField[T]

SRD adds SRD to the field's shared currency allowlist.

func (CurrencyField[T]) SSP added in v0.2.0

func (b CurrencyField[T]) SSP() CurrencyField[T]

SSP adds SSP to the field's shared currency allowlist.

func (CurrencyField[T]) STN added in v0.2.0

func (b CurrencyField[T]) STN() CurrencyField[T]

STN adds STN to the field's shared currency allowlist.

func (CurrencyField[T]) SVC added in v0.2.0

func (b CurrencyField[T]) SVC() CurrencyField[T]

SVC adds SVC to the field's shared currency allowlist.

func (CurrencyField[T]) SYP added in v0.2.0

func (b CurrencyField[T]) SYP() CurrencyField[T]

SYP adds SYP to the field's shared currency allowlist.

func (CurrencyField[T]) SZL added in v0.2.0

func (b CurrencyField[T]) SZL() CurrencyField[T]

SZL adds SZL to the field's shared currency allowlist.

func (CurrencyField[T]) THB added in v0.2.0

func (b CurrencyField[T]) THB() CurrencyField[T]

THB adds THB to the field's shared currency allowlist.

func (CurrencyField[T]) TJS added in v0.2.0

func (b CurrencyField[T]) TJS() CurrencyField[T]

TJS adds TJS to the field's shared currency allowlist.

func (CurrencyField[T]) TMT added in v0.2.0

func (b CurrencyField[T]) TMT() CurrencyField[T]

TMT adds TMT to the field's shared currency allowlist.

func (CurrencyField[T]) TND added in v0.2.0

func (b CurrencyField[T]) TND() CurrencyField[T]

TND adds TND to the field's shared currency allowlist.

func (CurrencyField[T]) TOP added in v0.2.0

func (b CurrencyField[T]) TOP() CurrencyField[T]

TOP adds TOP to the field's shared currency allowlist.

func (CurrencyField[T]) TRY added in v0.2.0

func (b CurrencyField[T]) TRY() CurrencyField[T]

TRY adds TRY to the field's shared currency allowlist.

func (CurrencyField[T]) TTD added in v0.2.0

func (b CurrencyField[T]) TTD() CurrencyField[T]

TTD adds TTD to the field's shared currency allowlist.

func (CurrencyField[T]) TWD added in v0.2.0

func (b CurrencyField[T]) TWD() CurrencyField[T]

TWD adds TWD to the field's shared currency allowlist.

func (CurrencyField[T]) TZS added in v0.2.0

func (b CurrencyField[T]) TZS() CurrencyField[T]

TZS adds TZS to the field's shared currency allowlist.

func (CurrencyField[T]) UAH added in v0.2.0

func (b CurrencyField[T]) UAH() CurrencyField[T]

UAH adds UAH to the field's shared currency allowlist.

func (CurrencyField[T]) UGX added in v0.2.0

func (b CurrencyField[T]) UGX() CurrencyField[T]

UGX adds UGX to the field's shared currency allowlist.

func (CurrencyField[T]) USD added in v0.2.0

func (b CurrencyField[T]) USD() CurrencyField[T]

USD adds USD to the field's shared currency allowlist.

func (CurrencyField[T]) USN added in v0.2.0

func (b CurrencyField[T]) USN() CurrencyField[T]

USN adds USN to the field's shared currency allowlist.

func (CurrencyField[T]) UYI added in v0.2.0

func (b CurrencyField[T]) UYI() CurrencyField[T]

UYI adds UYI to the field's shared currency allowlist.

func (CurrencyField[T]) UYU added in v0.2.0

func (b CurrencyField[T]) UYU() CurrencyField[T]

UYU adds UYU to the field's shared currency allowlist.

func (CurrencyField[T]) UYW added in v0.2.0

func (b CurrencyField[T]) UYW() CurrencyField[T]

UYW adds UYW to the field's shared currency allowlist.

func (CurrencyField[T]) UZS added in v0.2.0

func (b CurrencyField[T]) UZS() CurrencyField[T]

UZS adds UZS to the field's shared currency allowlist.

func (CurrencyField[T]) Using added in v0.2.0

func (b CurrencyField[T]) Using(rule Rule[T]) CurrencyField[T]

Using attaches an application validator for the exact currency-code input type.

func (CurrencyField[T]) VED added in v0.2.0

func (b CurrencyField[T]) VED() CurrencyField[T]

VED adds VED to the field's shared currency allowlist.

func (CurrencyField[T]) VES added in v0.2.0

func (b CurrencyField[T]) VES() CurrencyField[T]

VES adds VES to the field's shared currency allowlist.

func (CurrencyField[T]) VND added in v0.2.0

func (b CurrencyField[T]) VND() CurrencyField[T]

VND adds VND to the field's shared currency allowlist.

func (CurrencyField[T]) VUV added in v0.2.0

func (b CurrencyField[T]) VUV() CurrencyField[T]

VUV adds VUV to the field's shared currency allowlist.

func (CurrencyField[T]) WST added in v0.2.0

func (b CurrencyField[T]) WST() CurrencyField[T]

WST adds WST to the field's shared currency allowlist.

func (CurrencyField[T]) XAD added in v0.2.0

func (b CurrencyField[T]) XAD() CurrencyField[T]

XAD adds XAD to the field's shared currency allowlist.

func (CurrencyField[T]) XAF added in v0.2.0

func (b CurrencyField[T]) XAF() CurrencyField[T]

XAF adds XAF to the field's shared currency allowlist.

func (CurrencyField[T]) XAG added in v0.2.0

func (b CurrencyField[T]) XAG() CurrencyField[T]

XAG adds XAG to the field's shared currency allowlist.

func (CurrencyField[T]) XAU added in v0.2.0

func (b CurrencyField[T]) XAU() CurrencyField[T]

XAU adds XAU to the field's shared currency allowlist.

func (CurrencyField[T]) XBA added in v0.2.0

func (b CurrencyField[T]) XBA() CurrencyField[T]

XBA adds XBA to the field's shared currency allowlist.

func (CurrencyField[T]) XBB added in v0.2.0

func (b CurrencyField[T]) XBB() CurrencyField[T]

XBB adds XBB to the field's shared currency allowlist.

func (CurrencyField[T]) XBC added in v0.2.0

func (b CurrencyField[T]) XBC() CurrencyField[T]

XBC adds XBC to the field's shared currency allowlist.

func (CurrencyField[T]) XBD added in v0.2.0

func (b CurrencyField[T]) XBD() CurrencyField[T]

XBD adds XBD to the field's shared currency allowlist.

func (CurrencyField[T]) XCD added in v0.2.0

func (b CurrencyField[T]) XCD() CurrencyField[T]

XCD adds XCD to the field's shared currency allowlist.

func (CurrencyField[T]) XCG added in v0.2.0

func (b CurrencyField[T]) XCG() CurrencyField[T]

XCG adds XCG to the field's shared currency allowlist.

func (CurrencyField[T]) XDR added in v0.2.0

func (b CurrencyField[T]) XDR() CurrencyField[T]

XDR adds XDR to the field's shared currency allowlist.

func (CurrencyField[T]) XOF added in v0.2.0

func (b CurrencyField[T]) XOF() CurrencyField[T]

XOF adds XOF to the field's shared currency allowlist.

func (CurrencyField[T]) XPD added in v0.2.0

func (b CurrencyField[T]) XPD() CurrencyField[T]

XPD adds XPD to the field's shared currency allowlist.

func (CurrencyField[T]) XPF added in v0.2.0

func (b CurrencyField[T]) XPF() CurrencyField[T]

XPF adds XPF to the field's shared currency allowlist.

func (CurrencyField[T]) XPT added in v0.2.0

func (b CurrencyField[T]) XPT() CurrencyField[T]

XPT adds XPT to the field's shared currency allowlist.

func (CurrencyField[T]) XSU added in v0.2.0

func (b CurrencyField[T]) XSU() CurrencyField[T]

XSU adds XSU to the field's shared currency allowlist.

func (CurrencyField[T]) XTS added in v0.2.0

func (b CurrencyField[T]) XTS() CurrencyField[T]

XTS adds XTS to the field's shared currency allowlist.

func (CurrencyField[T]) XUA added in v0.2.0

func (b CurrencyField[T]) XUA() CurrencyField[T]

XUA adds XUA to the field's shared currency allowlist.

func (CurrencyField[T]) XXX added in v0.2.0

func (b CurrencyField[T]) XXX() CurrencyField[T]

XXX adds XXX to the field's shared currency allowlist.

func (CurrencyField[T]) YER added in v0.2.0

func (b CurrencyField[T]) YER() CurrencyField[T]

YER adds YER to the field's shared currency allowlist.

func (CurrencyField[T]) ZAR added in v0.2.0

func (b CurrencyField[T]) ZAR() CurrencyField[T]

ZAR adds ZAR to the field's shared currency allowlist.

func (CurrencyField[T]) ZMW added in v0.2.0

func (b CurrencyField[T]) ZMW() CurrencyField[T]

ZMW adds ZMW to the field's shared currency allowlist.

func (CurrencyField[T]) ZWG added in v0.2.0

func (b CurrencyField[T]) ZWG() CurrencyField[T]

ZWG adds ZWG to the field's shared currency allowlist.

type DecimalField added in v0.2.0

type DecimalField[T ~string] struct {
	// contains filtered or unexported fields
}

DecimalField is an immutable fluent chain for exact plain-decimal text. T may be an application-defined string type; submitted text is never rounded or rewritten.

func Decimal added in v0.2.0

func Decimal[T ~string](path string, value T) DecimalField[T]

Decimal starts a deferred chain for signed decimal text without exponent notation. Values require ASCII integer digits and may include a fractional part with digits after the point.

func (DecimalField[T]) Check added in v0.2.0

func (b DecimalField[T]) Check(check func(context.Context, T) error) DecimalField[T]

Check attaches a context-aware application check without converting the submitted text.

func (DecimalField[T]) Equal added in v0.2.0

func (b DecimalField[T]) Equal(other T) DecimalField[T]

Equal compares numeric value exactly without exposing its target; written scale may differ.

func (DecimalField[T]) GreaterThan added in v0.2.0

func (b DecimalField[T]) GreaterThan(other T) DecimalField[T]

GreaterThan requires a strict lower bound without exposing the comparison value in failures.

func (DecimalField[T]) Label added in v0.2.0

func (b DecimalField[T]) Label(label string) DecimalField[T]

Label sets the human-readable field name without changing its output path.

func (DecimalField[T]) LessThan added in v0.2.0

func (b DecimalField[T]) LessThan(other T) DecimalField[T]

LessThan requires a strict upper bound without exposing the comparison value in failures.

func (DecimalField[T]) Max added in v0.2.0

func (b DecimalField[T]) Max(max T) DecimalField[T]

Max requires an exact inclusive upper bound expressed as plain decimal text.

func (DecimalField[T]) MaxScale added in v0.2.0

func (b DecimalField[T]) MaxScale(max int) DecimalField[T]

MaxScale permits at most max written fractional digits, counting trailing zeros.

func (DecimalField[T]) Message added in v0.2.0

func (b DecimalField[T]) Message(message string) DecimalField[T]

Message overrides the preceding rule message while preserving its code.

func (DecimalField[T]) Min added in v0.2.0

func (b DecimalField[T]) Min(min T) DecimalField[T]

Min requires an exact inclusive lower bound expressed as plain decimal text.

func (DecimalField[T]) Required added in v0.2.0

func (b DecimalField[T]) Required() DecimalField[T]

Required rejects empty text before decimal syntax and content checks run.

func (DecimalField[T]) RequiredIf added in v0.2.0

func (b DecimalField[T]) RequiredIf(condition bool) DecimalField[T]

RequiredIf rejects empty text when condition is true; decimal syntax checks still apply.

func (DecimalField[T]) Using added in v0.2.0

func (b DecimalField[T]) Using(rule Rule[T]) DecimalField[T]

Using attaches a reusable validator for the exact decimal-text type.

type Errors

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

Errors contains ordered field failures and supports errors.As.

func (*Errors) Error

func (e *Errors) Error() string

Error returns field messages in declaration order.

func (*Errors) First

func (e *Errors) First(path string) string

First returns the first message at path, or an empty string if none exists.

func (*Errors) Issues

func (e *Errors) Issues() []Issue

Issues returns ordered copies of issues and their constraint parameters.

func (*Errors) Messages

func (e *Errors) Messages() map[string][]string

Messages returns an independent field-to-messages map for form or API responses.

type Field

type Field interface {
	// contains filtered or unexported methods
}

Field is a deferred validation operation constructed by a typed builder or group.

func Group

func Group(path string, fields ...Field) Field

Group prefixes child paths with a literal parent label.

func Optional

func Optional[T any](value *T, build func(T) Field) Field

Optional skips nil pointers and builds validation lazily for non-nil values.

func When

func When(condition bool, makeField func() Field) Field

When evaluates the callback lazily only when condition is true.

type Input

type Input[T any] struct {
	// contains filtered or unexported fields
}

Input preserves whether JSON supplied a value, null, or no property at all. Its zero value is absent; use json's omitzero option to omit absent properties. Decoding T uses json.Unmarshal, so enclosing decoder options do not propagate.

func Null

func Null[T any]() Input[T]

Null constructs an explicitly null input.

func Provided

func Provided[T any](value T) Input[T]

Provided constructs an input containing a supplied value, including zero values.

func (Input[T]) Get

func (i Input[T]) Get() (T, bool)

Get returns the supplied value and reports whether it is present and non-null.

func (Input[T]) IsNull

func (i Input[T]) IsNull() bool

IsNull reports whether a supplied property was explicitly null.

func (Input[T]) IsPresent

func (i Input[T]) IsPresent() bool

IsPresent reports whether a property was supplied, including explicit null.

func (Input[T]) IsZero

func (i Input[T]) IsZero() bool

IsZero lets encoding/json omit absent properties with omitzero.

func (Input[T]) MarshalJSON

func (i Input[T]) MarshalJSON() ([]byte, error)

MarshalJSON emits null for absent or null inputs and otherwise encodes the value.

func (*Input[T]) UnmarshalJSON

func (i *Input[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON replaces the input only after a complete successful decode.

type Issue

type Issue struct {
	Path       string            `json:"path"`
	Code       string            `json:"code"`
	Message    string            `json:"message"`
	Parameters map[string]string `json:"parameters,omitempty"`
}

Issue describes a failed field without retaining its submitted value.

type MapField

type MapField[T any] struct {
	// contains filtered or unexported fields
}

MapField validates a borrowed string-keyed map with deterministic child paths.

func Map

func Map[T any](path string, value map[string]T) MapField[T]

Map starts a deferred chain for a borrowed string-keyed map.

func (MapField[T]) Check

func (b MapField[T]) Check(check func(context.Context, map[string]T) error) MapField[T]

Check attaches a context-aware application validator for the map.

func (MapField[T]) Each

func (b MapField[T]) Each(fields func(string, T) []Field) MapField[T]

Each constructs key and value checks in sorted key order after parent constraints pass.

func (MapField[T]) HasKey

func (b MapField[T]) HasKey(key string) MapField[T]

HasKey requires a literal key without exposing it in failure messages.

func (MapField[T]) Label

func (b MapField[T]) Label(label string) MapField[T]

Label changes human-readable prose without changing map paths.

func (MapField[T]) Len

func (b MapField[T]) Len(length int) MapField[T]

Len requires exactly length entries.

func (MapField[T]) Max

func (b MapField[T]) Max(max int) MapField[T]

Max permits at most max entries.

func (MapField[T]) Message

func (b MapField[T]) Message(message string) MapField[T]

Message customizes the preceding parent constraint while preserving its code.

func (MapField[T]) Min

func (b MapField[T]) Min(min int) MapField[T]

Min requires at least min entries.

func (MapField[T]) OnlyKeys

func (b MapField[T]) OnlyKeys(keys ...string) MapField[T]

OnlyKeys permits only the listed keys, copying configuration independently of the caller.

func (MapField[T]) Required

func (b MapField[T]) Required() MapField[T]

Required rejects nil and empty maps before content checks.

func (MapField[T]) RequiredIf

func (b MapField[T]) RequiredIf(condition bool) MapField[T]

RequiredIf enforces a nonempty map only when condition is true.

func (MapField[T]) Using

func (b MapField[T]) Using(rule Rule[map[string]T]) MapField[T]

Using attaches an application validator for the complete map value.

type NumberField

type NumberField[T Numeric] struct {
	// contains filtered or unexported fields
}

NumberField is an immutable fluent chain for number values.

func Number

func Number[T Numeric](path string, value T) NumberField[T]

Number starts a deferred chain for a borrowed application value.

func (NumberField[T]) Check

func (b NumberField[T]) Check(check func(context.Context, T) error) NumberField[T]

Check attaches a context-aware application check.

func (NumberField[T]) Equal

func (b NumberField[T]) Equal(other T) NumberField[T]

Equal requires the other value without exposing it in error messages.

func (NumberField[T]) GreaterThan

func (b NumberField[T]) GreaterThan(other T) NumberField[T]

GreaterThan requires a strict lower bound in the field's numeric type.

func (NumberField[T]) In

func (b NumberField[T]) In(values ...T) NumberField[T]

In permits only finite listed values and owns its constraint slice.

func (NumberField[T]) Label

func (b NumberField[T]) Label(label string) NumberField[T]

Label sets the human-readable field name without changing its output path.

func (NumberField[T]) LessThan

func (b NumberField[T]) LessThan(other T) NumberField[T]

LessThan requires a strict upper bound in the field's numeric type.

func (NumberField[T]) Max

func (b NumberField[T]) Max(max T) NumberField[T]

Max requires an inclusive upper bound in the field's exact numeric type.

func (NumberField[T]) Message

func (b NumberField[T]) Message(message string) NumberField[T]

Message overrides the preceding rule message while preserving its code.

func (NumberField[T]) Min

func (b NumberField[T]) Min(min T) NumberField[T]

Min requires an inclusive lower bound in the field's exact numeric type.

func (NumberField[T]) MultipleOf

func (b NumberField[T]) MultipleOf(divisor T) NumberField[T]

MultipleOf requires an exact remainder of zero; floats use binary math.Mod semantics.

func (NumberField[T]) NotEqual

func (b NumberField[T]) NotEqual(other T) NumberField[T]

NotEqual rejects the other finite value without exposing it in errors.

func (NumberField[T]) NotIn

func (b NumberField[T]) NotIn(values ...T) NumberField[T]

NotIn rejects the finite listed values and owns its constraint slice.

func (NumberField[T]) Using

func (b NumberField[T]) Using(rule Rule[T]) NumberField[T]

Using attaches a reusable validator for the exact value type.

type Numeric

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64
}

Numeric permits all Go integer and floating-point types, including defined types.

type PresenceField

type PresenceField[T any] struct {
	// contains filtered or unexported fields
}

PresenceField validates an Input while preserving omitted and explicit-null states.

func Presence

func Presence[T any](path string, input Input[T], build func(T) Field) PresenceField[T]

Presence defers child validation until input contains a non-null value. Use an empty child path to retain path, or a named child to append a segment.

func (PresenceField[T]) Label

func (b PresenceField[T]) Label(label string) PresenceField[T]

Label sets the human-readable name for presence failures.

func (PresenceField[T]) Message

func (b PresenceField[T]) Message(message string) PresenceField[T]

Message overrides the preceding presence rule message while preserving its code.

func (PresenceField[T]) Nullable

func (b PresenceField[T]) Nullable() PresenceField[T]

Nullable permits explicit null without constructing child validation.

func (PresenceField[T]) Required

func (b PresenceField[T]) Required() PresenceField[T]

Required requires a supplied, non-null value; zero values remain valid.

func (PresenceField[T]) RequiredIf

func (b PresenceField[T]) RequiredIf(condition bool) PresenceField[T]

RequiredIf requires a supplied, non-null value when condition is true.

type Rule

type Rule[T any] interface {
	// Validate returns nil, an explicit Violation, or an operational error.
	Validate(value T) error
}

Rule validates a value using application-owned configuration and dependencies.

func All

func All[T any](rules ...Rule[T]) Rule[T]

All requires every rule, returning the first violation or operational error.

func Any

func Any[T any](rules ...Rule[T]) Rule[T]

Any accepts a value when a rule succeeds; operational errors abort evaluation.

func Not

func Not[T any](rule Rule[T]) Rule[T]

Not inverts a rule's input-validity result while preserving operational errors.

func UniqueBy

func UniqueBy[T any, K comparable](key func(T) K) Rule[[]T]

UniqueBy requires distinct comparable keys without retaining keys in failures.

type RuleFunc

type RuleFunc[T any] func(T) error

RuleFunc adapts an ordinary function into a reusable typed rule.

func (RuleFunc[T]) Validate

func (f RuleFunc[T]) Validate(value T) error

Validate evaluates the adapted function.

type RuleWithContext

type RuleWithContext[T any] interface {
	Rule[T]
	// ValidateContext uses the evaluation context for dependent operations.
	ValidateContext(ctx context.Context, value T) error
}

RuleWithContext propagates request cancellation to dependent operations.

type SliceField

type SliceField[T any] struct {
	// contains filtered or unexported fields
}

SliceField is an immutable fluent chain for slice values.

func Slice

func Slice[T any](path string, value []T) SliceField[T]

Slice starts a deferred chain for a borrowed application value.

func (SliceField[T]) Check

func (b SliceField[T]) Check(check func(context.Context, []T) error) SliceField[T]

Check attaches a context-aware application check.

func (SliceField[T]) Contains

func (b SliceField[T]) Contains(target T) SliceField[T]

Contains requires an element equal under reflect.DeepEqual; the target value is borrowed.

func (SliceField[T]) Each

func (b SliceField[T]) Each(fields func(T) []Field) SliceField[T]

Each lazily constructs child fields for each element after parent checks pass.

func (SliceField[T]) Label

func (b SliceField[T]) Label(label string) SliceField[T]

Label sets the human-readable field name without changing its output path.

func (SliceField[T]) Len

func (b SliceField[T]) Len(length int) SliceField[T]

Len requires exactly length elements.

func (SliceField[T]) Max

func (b SliceField[T]) Max(max int) SliceField[T]

Max permits at most max elements.

func (SliceField[T]) Message

func (b SliceField[T]) Message(message string) SliceField[T]

Message overrides the preceding rule message while preserving its code.

func (SliceField[T]) Min

func (b SliceField[T]) Min(min int) SliceField[T]

Min requires at least min elements.

func (SliceField[T]) NotContains

func (b SliceField[T]) NotContains(target T) SliceField[T]

NotContains rejects an element equal under reflect.DeepEqual; the target value is borrowed.

func (SliceField[T]) Required

func (b SliceField[T]) Required() SliceField[T]

Required rejects empty and nil slices before evaluating child fields.

func (SliceField[T]) RequiredIf

func (b SliceField[T]) RequiredIf(condition bool) SliceField[T]

RequiredIf applies a nonempty constraint only when condition is true.

func (SliceField[T]) Unique

func (b SliceField[T]) Unique() SliceField[T]

Unique requires distinct Go-comparable elements; use UniqueBy for structs with slices or maps.

func (SliceField[T]) Using

func (b SliceField[T]) Using(rule Rule[[]T]) SliceField[T]

Using attaches a reusable validator for the exact value type.

type StringField

type StringField[T ~string] struct {
	// contains filtered or unexported fields
}

StringField is an immutable fluent chain for string values.

func String

func String[T ~string](path string, value T) StringField[T]

String starts a deferred chain for a borrowed application value.

func (StringField[T]) Check

func (b StringField[T]) Check(check func(context.Context, T) error) StringField[T]

Check attaches a context-aware application check.

func (StringField[T]) Contains

func (b StringField[T]) Contains(text string) StringField[T]

Contains requires the configured substring without modifying case or whitespace.

func (StringField[T]) EndsWith

func (b StringField[T]) EndsWith(suffix string) StringField[T]

EndsWith requires a literal suffix.

func (StringField[T]) Equal

func (b StringField[T]) Equal(other T) StringField[T]

Equal requires the other value without retaining it in failure details.

func (StringField[T]) In

func (b StringField[T]) In(values ...T) StringField[T]

In permits only the given values and owns a copy of their slice.

func (StringField[T]) IsASCII

func (b StringField[T]) IsASCII() StringField[T]

IsASCII requires nonempty ASCII text, including control bytes.

func (StringField[T]) IsAlpha

func (b StringField[T]) IsAlpha() StringField[T]

IsAlpha requires nonempty ASCII letters.

func (StringField[T]) IsAlphanumeric

func (b StringField[T]) IsAlphanumeric() StringField[T]

IsAlphanumeric requires nonempty ASCII letters and digits.

func (StringField[T]) IsBase64

func (b StringField[T]) IsBase64() StringField[T]

IsBase64 requires strict standard padded Base64 without whitespace.

func (StringField[T]) IsBase64URL

func (b StringField[T]) IsBase64URL() StringField[T]

IsBase64URL requires strict padded or raw URL-safe Base64.

func (StringField[T]) IsCIDR

func (b StringField[T]) IsCIDR() StringField[T]

IsCIDR requires an IP prefix without normalizing host bits.

func (StringField[T]) IsDate

func (b StringField[T]) IsDate(layout string) StringField[T]

IsDate requires a value parseable with a Go time layout, using UTC for unzoned input.

func (StringField[T]) IsDateIn

func (b StringField[T]) IsDateIn(layout string, location *time.Location) StringField[T]

IsDateIn interprets unzoned input in location without changing the supplied string.

func (StringField[T]) IsDigits

func (b StringField[T]) IsDigits() StringField[T]

IsDigits requires nonempty ASCII decimal digits.

func (StringField[T]) IsE164

func (b StringField[T]) IsE164() StringField[T]

IsE164 requires international phone-number syntax, without assignment checks.

func (StringField[T]) IsEmail

func (b StringField[T]) IsEmail() StringField[T]

IsEmail requires a bare ASCII mailbox with a dotted domain.

func (StringField[T]) IsHostname

func (b StringField[T]) IsHostname() StringField[T]

IsHostname requires ASCII DNS labels, optionally ending in a root dot.

func (StringField[T]) IsIP

func (b StringField[T]) IsIP() StringField[T]

IsIP requires an unzoned IP address literal.

func (StringField[T]) IsIPv4

func (b StringField[T]) IsIPv4() StringField[T]

IsIPv4 requires an IPv4 address literal.

func (StringField[T]) IsIPv6

func (b StringField[T]) IsIPv6() StringField[T]

IsIPv6 requires an unzoned IPv6 address literal.

func (StringField[T]) IsJSON

func (b StringField[T]) IsJSON() StringField[T]

IsJSON requires any valid JSON document, including scalar values.

func (StringField[T]) IsLowercase

func (b StringField[T]) IsLowercase() StringField[T]

IsLowercase requires valid UTF-8 with at least one cased letter and no uppercase or titlecase letters.

func (StringField[T]) IsMAC

func (b StringField[T]) IsMAC() StringField[T]

IsMAC requires a 48-bit or 64-bit link-layer address.

func (StringField[T]) IsULID

func (b StringField[T]) IsULID() StringField[T]

IsULID requires a case-insensitive 128-bit ULID.

func (StringField[T]) IsURL

func (b StringField[T]) IsURL() StringField[T]

IsURL requires an absolute HTTP or HTTPS URL with a host.

func (StringField[T]) IsUTF8

func (b StringField[T]) IsUTF8() StringField[T]

IsUTF8 requires valid UTF-8, including empty text.

func (StringField[T]) IsUUID

func (b StringField[T]) IsUUID() StringField[T]

IsUUID requires a canonical UUID, including nil and max UUIDs.

func (StringField[T]) IsUUIDv4

func (b StringField[T]) IsUUIDv4() StringField[T]

IsUUIDv4 requires a canonical version 4 UUID.

func (StringField[T]) IsUUIDv7

func (b StringField[T]) IsUUIDv7() StringField[T]

IsUUIDv7 requires a canonical version 7 UUID.

func (StringField[T]) IsUppercase

func (b StringField[T]) IsUppercase() StringField[T]

IsUppercase requires valid UTF-8 with at least one cased letter and no lowercase or titlecase letters.

func (StringField[T]) Label

func (b StringField[T]) Label(label string) StringField[T]

Label sets the human-readable field name without changing its output path.

func (StringField[T]) Len

func (b StringField[T]) Len(length int) StringField[T]

Len requires exactly length Unicode code points.

func (StringField[T]) Match

func (b StringField[T]) Match(pattern *regexp.Regexp) StringField[T]

Match requires a match against an already compiled, caller-owned expression.

func (StringField[T]) Max

func (b StringField[T]) Max(max int) StringField[T]

Max permits at most max Unicode code points.

func (StringField[T]) Message

func (b StringField[T]) Message(message string) StringField[T]

Message overrides the preceding rule message while preserving its code.

func (StringField[T]) Min

func (b StringField[T]) Min(min int) StringField[T]

Min requires at least min Unicode code points.

func (StringField[T]) NotBlank

func (b StringField[T]) NotBlank() StringField[T]

NotBlank rejects empty strings and strings containing only Unicode whitespace.

func (StringField[T]) NotContains

func (b StringField[T]) NotContains(text string) StringField[T]

NotContains rejects the configured substring without exposing it in failures.

func (StringField[T]) NotEqual

func (b StringField[T]) NotEqual(other T) StringField[T]

NotEqual rejects the other value without retaining it in failure details.

func (StringField[T]) NotIn

func (b StringField[T]) NotIn(values ...T) StringField[T]

NotIn rejects the listed values and owns a copy of their slice.

func (StringField[T]) Required

func (b StringField[T]) Required() StringField[T]

Required rejects an empty string before content rules run.

func (StringField[T]) RequiredIf

func (b StringField[T]) RequiredIf(condition bool) StringField[T]

RequiredIf applies an emptiness check only when condition is true.

func (StringField[T]) StartsWith

func (b StringField[T]) StartsWith(prefix string) StringField[T]

StartsWith requires a literal prefix.

func (StringField[T]) Using

func (b StringField[T]) Using(rule Rule[T]) StringField[T]

Using attaches a reusable validator for the exact value type.

type TimeField

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

TimeField is an immutable fluent chain for time instants.

func Time

func Time(path string, value time.Time) TimeField

Time starts a deferred chain using instant comparisons across time zones.

func (TimeField) After

func (b TimeField) After(other time.Time) TimeField

After requires an instant strictly later than other.

func (TimeField) Before

func (b TimeField) Before(other time.Time) TimeField

Before requires an instant strictly earlier than other.

func (TimeField) Check

func (b TimeField) Check(check func(context.Context, time.Time) error) TimeField

Check attaches a context-aware application check.

func (TimeField) Equal

func (b TimeField) Equal(other time.Time) TimeField

Equal requires the same instant without exposing the expected value in failures.

func (TimeField) Label

func (b TimeField) Label(label string) TimeField

Label sets the human-readable field name without changing its output path.

func (TimeField) Max

func (b TimeField) Max(max time.Time) TimeField

Max permits instants on or before max.

func (TimeField) Message

func (b TimeField) Message(message string) TimeField

Message overrides the preceding rule message while preserving its code.

func (TimeField) Min

func (b TimeField) Min(min time.Time) TimeField

Min permits instants on or after min.

func (TimeField) Required

func (b TimeField) Required() TimeField

Required rejects the zero time before content rules run.

func (TimeField) RequiredIf

func (b TimeField) RequiredIf(condition bool) TimeField

RequiredIf rejects the zero time when condition is true.

func (TimeField) Using

func (b TimeField) Using(rule Rule[time.Time]) TimeField

Using attaches a reusable validator for time values.

type Validator

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

Validator is an immutable evaluation policy; its zero value uses package defaults. Rule and formatter callbacks retain application ownership and concurrency requirements.

func New

func New() Validator

New creates a validator with first-violation-per-field collection and default messages.

func (Validator) CollectAll

func (v Validator) CollectAll() Validator

CollectAll collects all content failures per field; required failures still stop that field.

func (Validator) FormatMessages

func (v Validator) FormatMessages(format func(Issue) string) Validator

FormatMessages formats violations by path, code, and owned parameters, unless Message overrides it. The callback receives no submitted value and may provide application-localized messages.

func (Validator) StopOnFirstError

func (v Validator) StopOnFirstError() Validator

StopOnFirstError stops the entire evaluation after its first input violation.

func (Validator) Validate

func (v Validator) Validate(fields ...Field) error

Validate evaluates fields with a background context and the configured policy.

func (Validator) ValidateContext

func (v Validator) ValidateContext(ctx context.Context, fields ...Field) error

ValidateContext evaluates with request cancellation and the configured collection policy.

type ValueField

type ValueField[T any] struct {
	// contains filtered or unexported fields
}

ValueField is an immutable fluent chain for value values.

func Value

func Value[T any](path string, value T) ValueField[T]

Value starts a deferred chain for a borrowed application value.

func (ValueField[T]) Check

func (b ValueField[T]) Check(check func(context.Context, T) error) ValueField[T]

Check attaches a context-aware application check.

func (ValueField[T]) Label

func (b ValueField[T]) Label(label string) ValueField[T]

Label sets the human-readable field name without changing its output path.

func (ValueField[T]) Message

func (b ValueField[T]) Message(message string) ValueField[T]

Message overrides the preceding rule message while preserving its code.

func (ValueField[T]) Using

func (b ValueField[T]) Using(rule Rule[T]) ValueField[T]

Using attaches a reusable validator for the exact value type.

type Violation

type Violation = violation.Violation

Violation is a coded, client-facing failure returned by a rule.

func Invalid

func Invalid(code, message string) *Violation

Invalid creates a violation with a stable code and a message safe for clients.

Directories

Path Synopsis
examples
advanced command
constraints command
context command
currency command
custom command
decimal command
domain command
errors command
formats command
moreformats command
nested command
patch command
policies command
presence command
quickstart command
time command
internal
formats
Package formats owns the checks behind fluent string format methods.
Package formats owns the checks behind fluent string format methods.
violation
Package violation shares coded failures between validation and format rules.
Package violation shares coded failures between validation and format rules.

Jump to

Keyboard shortcuts

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