types

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilPointerToArray    = errors.New("nil pointer to array")
	ErrNilPointer           = errors.New("nil pointer")
	ErrExpectedArrayOrSlice = errors.New("expected array or slice")
)

Static error variables

View Source
var (
	ErrSchemaIsNil                   = errors.New("schema is nil")
	ErrSchemaInternalsIsNil          = errors.New("schema internals is nil")
	ErrNoDiscriminatorValuesFound    = errors.New("no discriminator values found for field")
	ErrOptionIsNil                   = errors.New("option is nil")
	ErrDuplicateDiscriminatorValue   = errors.New("duplicate discriminator value")
	ErrFailedToBuildDiscriminatorMap = errors.New("failed to build discriminator map")
	ErrNoValidDiscriminatorValues    = errors.New("no valid discriminator values found for field")
)

Static error variables

View Source
var (
	PrecisionMinute      = func() *int { i := -1; return &i }()
	PrecisionSecond      = func() *int { i := 0; return &i }()
	PrecisionDecisecond  = func() *int { i := 1; return &i }()
	PrecisionCentisecond = func() *int { i := 2; return &i }()
	PrecisionMillisecond = func() *int { i := 3; return &i }()
	PrecisionMicrosecond = func() *int { i := 6; return &i }()
	PrecisionNanosecond  = func() *int { i := 9; return &i }()
)
View Source
var (
	ErrNilPointerCannotConvertToObject = errors.New("nil pointer cannot be converted to object")

	// Pick/Omit/Extend errors - Zod v4 compatible error messages
	// See: .reference/zod/packages/zod/src/v4/core/util.ts:599, 628, 664
	ErrPickRefinements   = errors.New(".pick() cannot be used on object schemas containing refinements")
	ErrOmitRefinements   = errors.New(".omit() cannot be used on object schemas containing refinements")
	ErrExtendRefinements = errors.New(".extend() cannot overwrite keys on object schemas containing refinements. Use .SafeExtend() instead")
	ErrUnrecognizedKey   = errors.New("unrecognized key")
)

Static error variables

View Source
var (
	ErrInternalMapType             = errors.New("internal error: T is not a map type")
	ErrInternalMapKeyNotString     = errors.New("internal error: map key is not string")
	ErrInternalCannotConvertValue  = errors.New("internal error: cannot convert value type")
	ErrInternalCannotConvertRecord = errors.New("internal error: cannot convert validated record back to T")
	ErrNilPointerToRecord          = errors.New("nil pointer to record")
	ErrNonStringKeyInMap           = errors.New("non-string key found in map, records require string keys")
	ErrExpectedMapStringAny        = errors.New("expected map[string]any")
	ErrValueValidationFailed       = errors.New("value validation failed for key")
)

Static error variables

View Source
var (
	ErrFieldNotFoundOrNotSettable = errors.New("field not found or not settable")
	ErrCannotAssignToField        = errors.New("cannot assign value to field of type")
)

Static error variables

View Source
var (
	ErrParseComplexUnexpectedType = errors.New("internal error: ParseComplex returned unexpected type")
)

Static error variables

Functions

This section is empty.

Types

type BigIntegerConstraint added in v0.3.0

type BigIntegerConstraint interface {
	*big.Int | **big.Int
}

BigIntegerConstraint restricts values to *big.Int or **big.Int.

type BoolConstraint added in v0.3.0

type BoolConstraint interface {
	~bool | ~*bool
}

BoolConstraint restricts values to bool or *bool.

type Complex64Constraint added in v0.3.0

type Complex64Constraint interface {
	complex64 | *complex64
}

Complex64Constraint defines constraint for complex64 types

type Complex128Constraint added in v0.3.0

type Complex128Constraint interface {
	complex128 | *complex128
}

Complex128Constraint defines constraint for complex128 types

type ComplexConstraint added in v0.3.0

type ComplexConstraint interface {
	complex64 | complex128 | *complex64 | *complex128
}

ComplexConstraint defines supported complex types for generic implementation

type EmailConstraint added in v0.3.0

type EmailConstraint interface {
	string | *string
}

type Float32Constraint added in v0.3.0

type Float32Constraint interface {
	float32 | *float32
}

Float32Constraint restricts values to float32 or *float32.

type Float64Constraint added in v0.3.0

type Float64Constraint interface {
	float64 | *float64
}

Float64Constraint restricts values to float64 or *float64.

type FloatConstraint added in v0.3.0

type FloatConstraint interface {
	~float32 | ~float64 | ~*float32 | ~*float64
}

FloatConstraint restricts values to supported float types or their pointers.

type FunctionConstraint added in v0.3.0

type FunctionConstraint interface {
	any | *any
}

FunctionConstraint restricts values to function or *function.

type FunctionParams

type FunctionParams struct {
	Input  core.ZodType[any] `json:"input,omitempty"`
	Output core.ZodType[any] `json:"output,omitempty"`
}

FunctionParams defines parameters for function schema creation

type IntegerConstraint added in v0.3.0

type IntegerConstraint interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~*int | ~*int8 | ~*int16 | ~*int32 | ~*int64 | ~*uint | ~*uint8 | ~*uint16 | ~*uint32 | ~*uint64
}

IntegerConstraint restricts values to supported integer types or their pointers.

type IsoConstraint added in v0.3.0

type IsoConstraint interface {
	string | *string
}

type IsoDatetimeOptions added in v0.3.0

type IsoDatetimeOptions struct {
	Precision *int // see Precision* constants
	Offset    bool // allow timezone offsets
	Local     bool // make trailing "Z" optional
}

type IsoTimeOptions added in v0.3.0

type IsoTimeOptions struct {
	Precision *int // fraction seconds precision (nil = any, -1 minute precision)
}

type JWTOptions added in v0.3.0

type JWTOptions struct {
	// Algorithm specifies the expected signing algorithm
	// If empty, any algorithm is accepted (basic structure validation only)
	Algorithm string
}

JWTOptions defines options for JWT validation

type LazyConstraint added in v0.3.0

type LazyConstraint interface {
	any | *any
}

LazyConstraint restricts values to any or *any for lazy schema types

type NetworkConstraint added in v0.3.0

type NetworkConstraint interface {
	string | *string
}

NetworkConstraint defines the constraint for network address types (string-based)

type ObjectMode

type ObjectMode string

ObjectMode defines how to handle unknown keys in object validation

const (
	ObjectModeStrict      ObjectMode = "strict"      // Reject unknown keys
	ObjectModeStrip       ObjectMode = "strip"       // Remove unknown keys
	ObjectModePassthrough ObjectMode = "passthrough" // Allow unknown keys
)

type StringBoolConstraint added in v0.3.0

type StringBoolConstraint interface {
	bool | *bool
}

StringBoolConstraint restricts values to bool or *bool for StringBool output.

type StringBoolOptions

type StringBoolOptions struct {
	Truthy []string // Values that evaluate to true
	Falsy  []string // Values that evaluate to false
	Case   string   // "sensitive" or "insensitive"
}

StringBoolOptions provides configuration for stringbool schema creation

type StringConstraint added in v0.3.0

type StringConstraint interface {
	~string | ~*string
}

StringConstraint restricts values to string or *string.

type TimeConstraint added in v0.3.0

type TimeConstraint interface {
	time.Time | *time.Time
}

TimeConstraint restricts values to time.Time or *time.Time.

type TupleConstraint added in v0.5.4

type TupleConstraint interface {
	[]any | *[]any
}

TupleConstraint defines valid constraint types for tuple schemas

type URLOptions added in v0.3.0

type URLOptions struct {
	// Hostname validation pattern
	Hostname *regexp.Regexp
	// Protocol validation pattern
	Protocol *regexp.Regexp
}

URLOptions defines options for URL validation (similar to IsoDatetimeOptions)

type ZodAny

type ZodAny[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodAny represents an any-value validation schema with dual generic parameters T = base type (any), R = constraint type (any or *any)

func Any

func Any(params ...any) *ZodAny[any, any]

Any creates any schema that accepts any value - returns value constraint

func AnyPtr added in v0.3.0

func AnyPtr(params ...any) *ZodAny[any, *any]

AnyPtr creates any schema that accepts any value - returns pointer constraint

func AnyTyped added in v0.3.0

func AnyTyped[T any, R any](params ...any) *ZodAny[T, R]

AnyTyped creates typed any schema with generic constraints

func (*ZodAny[T, R]) CloneFrom

func (z *ZodAny[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodAny[T, R]) Default

func (z *ZodAny[T, R]) Default(v T) *ZodAny[T, R]

Default preserves current constraint type R

func (*ZodAny[T, R]) DefaultFunc

func (z *ZodAny[T, R]) DefaultFunc(fn func() T) *ZodAny[T, R]

DefaultFunc preserves current constraint type R

func (*ZodAny[T, R]) Describe added in v0.5.4

func (z *ZodAny[T, R]) Describe(description string) *ZodAny[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodAny[T, R]) GetInternals

func (z *ZodAny[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodAny[T, R]) IsNilable added in v0.3.0

func (z *ZodAny[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodAny[T, R]) IsOptional added in v0.3.0

func (z *ZodAny[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodAny[T, R]) Meta added in v0.3.1

func (z *ZodAny[T, R]) Meta(meta core.GlobalMeta) *ZodAny[T, R]

Meta stores metadata for this any schema.

func (*ZodAny[T, R]) MustParse

func (z *ZodAny[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse is the variant that panics on error

func (*ZodAny[T, R]) Nilable

func (z *ZodAny[T, R]) Nilable() *ZodAny[T, *T]

Nilable makes the any type nilable and returns pointer constraint

func (*ZodAny[T, R]) NonOptional added in v0.3.0

func (z *ZodAny[T, R]) NonOptional() *ZodAny[T, T]

NonOptional removes Optional flag and returns base constraint type T.

func (*ZodAny[T, R]) Nullish

func (z *ZodAny[T, R]) Nullish() *ZodAny[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodAny[T, R]) Optional

func (z *ZodAny[T, R]) Optional() *ZodAny[T, *T]

Optional makes the any type optional and returns pointer constraint

func (*ZodAny[T, R]) Overwrite added in v0.3.0

func (z *ZodAny[T, R]) Overwrite(transform func(T) T, params ...any) *ZodAny[T, R]

Overwrite applies data transformation while preserving type structure This allows for data cleaning, normalization, and preprocessing operations

func (*ZodAny[T, R]) Parse

func (z *ZodAny[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse returns the input value as-is with modifier support using engine.ParsePrimitive

func (*ZodAny[T, R]) ParseAny added in v0.3.0

func (z *ZodAny[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodAny[T, R]) Pipe

func (z *ZodAny[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern.

func (*ZodAny[T, R]) Prefault

func (z *ZodAny[T, R]) Prefault(v T) *ZodAny[T, R]

Prefault provides fallback values on validation failure

func (*ZodAny[T, R]) PrefaultFunc

func (z *ZodAny[T, R]) PrefaultFunc(fn func() T) *ZodAny[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodAny[T, R]) Refine

func (z *ZodAny[T, R]) Refine(fn func(R) bool, args ...any) *ZodAny[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodAny[T, R]) RefineAny

func (z *ZodAny[T, R]) RefineAny(fn func(any) bool, args ...any) *ZodAny[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodAny[T, R]) StrictParse added in v0.4.0

func (z *ZodAny[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides type-safe parsing with compile-time guarantees using engine.ParsePrimitiveStrict

func (*ZodAny[T, R]) Transform

func (z *ZodAny[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern.

type ZodAnyDef

type ZodAnyDef struct {
	core.ZodTypeDef
}

ZodAnyDef defines the configuration for any value validation

type ZodAnyInternals

type ZodAnyInternals struct {
	core.ZodTypeInternals
	Def *ZodAnyDef // Schema definition
}

ZodAnyInternals contains any validator internal state

type ZodArray

type ZodArray[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodArray represents a type-safe fixed-length array validation schema with unified constraint T is the base array type ([]any), R is the constraint type ([]any | *[]any)

func Array

func Array(args ...any) *ZodArray[[]any, []any]

Array creates tuple schema with fixed elements Supports the following patterns: Array() - empty tuple Array([]any{String(), Int()}) - fixed length tuple Array([]any{String(), Int()}, Bool()) - tuple with rest parameter

Graceful handling: Non-[]any arguments are converted to single-element array for convenience

func ArrayPtr added in v0.3.0

func ArrayPtr(args ...any) *ZodArray[[]any, *[]any]

ArrayPtr creates pointer-capable tuple schema

Graceful handling: Non-[]any arguments are converted to single-element array for convenience

func ArrayTyped added in v0.3.0

func ArrayTyped[T any, R any](items []any, args ...any) *ZodArray[T, R]

ArrayTyped is the generic constructor for tuple schemas Supports explicit syntax only: ArrayTyped([]any{schemas...}) - fixed length tuple ArrayTyped([]any{schemas...}, params) - fixed length tuple with custom params ArrayTyped([]any{schemas...}, Rest) - tuple with rest parameter ArrayTyped([]any{schemas...}, Rest, params) - with custom params

func (*ZodArray[T, R]) And added in v0.5.4

func (z *ZodArray[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Array(gozod.String()).Min(1).And(gozod.Array(gozod.String()).Max(10))
result, _ := schema.Parse([]string{"a", "b"}) // Must satisfy both constraints

func (*ZodArray[T, R]) Check

func (z *ZodArray[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodArray[T, R]

Check adds a custom validation function that can report multiple issues for array schema.

func (*ZodArray[T, R]) CloneFrom

func (z *ZodArray[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodArray[T, R]) Default

func (z *ZodArray[T, R]) Default(v T) *ZodArray[T, R]

Default keeps the current generic constraint type R.

func (*ZodArray[T, R]) DefaultFunc

func (z *ZodArray[T, R]) DefaultFunc(fn func() T) *ZodArray[T, R]

DefaultFunc keeps the current generic constraint type R.

func (*ZodArray[T, R]) Describe added in v0.5.4

func (z *ZodArray[T, R]) Describe(description string) *ZodArray[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodArray[T, R]) Element

func (z *ZodArray[T, R]) Element(index int) any

Element returns the schema for the element at the given index

func (*ZodArray[T, R]) ExactOptional added in v0.5.4

func (z *ZodArray[T, R]) ExactOptional() *ZodArray[T, R]

ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional(), which accepts both absent keys AND nil values, ExactOptional() only accepts absent keys in object fields.

func (*ZodArray[T, R]) GetInternals

func (z *ZodArray[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodArray[T, R]) IsNilable added in v0.3.0

func (z *ZodArray[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodArray[T, R]) IsOptional added in v0.3.0

func (z *ZodArray[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodArray[T, R]) Items

func (z *ZodArray[T, R]) Items() []any

Items returns all element schemas

func (*ZodArray[T, R]) Length

func (z *ZodArray[T, R]) Length(exactLen int, args ...any) *ZodArray[T, R]

Length sets exact number of elements

func (*ZodArray[T, R]) Max

func (z *ZodArray[T, R]) Max(maxLen int, args ...any) *ZodArray[T, R]

Max sets maximum number of elements

func (*ZodArray[T, R]) Meta added in v0.3.1

func (z *ZodArray[T, R]) Meta(meta core.GlobalMeta) *ZodArray[T, R]

Meta stores metadata for this array schema in the global registry.

func (*ZodArray[T, R]) Min

func (z *ZodArray[T, R]) Min(minLen int, args ...any) *ZodArray[T, R]

Min sets minimum number of elements

func (*ZodArray[T, R]) MustParse

func (z *ZodArray[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodArray[T, R]) MustStrictParse added in v0.4.0

func (z *ZodArray[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodArray[T, R]) Nilable

func (z *ZodArray[T, R]) Nilable() *ZodArray[T, *T]

Nilable always returns *[]any constraint because the value may be nil.

func (*ZodArray[T, R]) NonEmpty

func (z *ZodArray[T, R]) NonEmpty(args ...any) *ZodArray[T, R]

NonEmpty requires at least one element

func (*ZodArray[T, R]) NonOptional added in v0.3.0

func (z *ZodArray[T, R]) NonOptional() *ZodArray[T, T]

NonOptional removes Optional flag and enforces non-nil value constraint (T). This mirrors the behaviour of Optional().NonOptional() in TS Zod, and produces dedicated "expected = nonoptional" error when input is nil.

func (*ZodArray[T, R]) Nullish

func (z *ZodArray[T, R]) Nullish() *ZodArray[T, *T]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodArray[T, R]) Optional

func (z *ZodArray[T, R]) Optional() *ZodArray[T, *T]

Optional always returns *[]any constraint because the optional value may be nil.

func (*ZodArray[T, R]) Or added in v0.5.4

func (z *ZodArray[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Array(gozod.String()).Or(gozod.Array(gozod.Int()))
result, _ := schema.Parse([]string{"a"})  // Accepts string array
result, _ = schema.Parse([]int{1, 2})     // Accepts int array

func (*ZodArray[T, R]) Overwrite added in v0.3.0

func (z *ZodArray[T, R]) Overwrite(transform func(R) R, params ...any) *ZodArray[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodArray[T, R]) Parse

func (z *ZodArray[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using array-specific parsing logic Parse validates input using array-specific parsing logic with engine.ParseComplex

func (*ZodArray[T, R]) ParseAny added in v0.3.0

func (z *ZodArray[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodArray[T, R]) Pipe

func (z *ZodArray[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

WrapFn Implementation:

  1. Create a target function that extracts T from constraint type R
  2. Apply the target schema to the extracted T
  3. Return a ZodPipe with the target function

Zero Redundancy:

  • No arrayTypeConverter structure needed
  • Direct function composition eliminates overhead
  • Type-safe extraction from constraint type R to T

Example:

arrayToString := Array([]any{String()}).Pipe(String())  // []any -> string conversion

func (*ZodArray[T, R]) Prefault

func (z *ZodArray[T, R]) Prefault(v T) *ZodArray[T, R]

Prefault provides fallback values on validation failure

func (*ZodArray[T, R]) PrefaultFunc

func (z *ZodArray[T, R]) PrefaultFunc(fn func() T) *ZodArray[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodArray[T, R]) Refine

func (z *ZodArray[T, R]) Refine(fn func(R) bool, params ...any) *ZodArray[T, R]

Refine applies type-safe validation that matches the schema's output type R.

func (*ZodArray[T, R]) RefineAny

func (z *ZodArray[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodArray[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodArray[T, R]) Rest added in v0.3.0

func (z *ZodArray[T, R]) Rest() any

Rest returns the rest parameter schema

func (*ZodArray[T, R]) StrictParse added in v0.4.0

func (z *ZodArray[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodArray[T, R]) Transform

func (z *ZodArray[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Array types implement direct extraction of T values for transformation.

type ZodArrayDef

type ZodArrayDef struct {
	core.ZodTypeDef
	Items []any // Element schemas for each position (type-erased for flexibility)
	Rest  any   // Rest schema for variadic elements (nil if no rest)
}

ZodArrayDef defines the schema definition for fixed-length array validation

type ZodArrayInternals

type ZodArrayInternals struct {
	core.ZodTypeInternals
	Def   *ZodArrayDef // Schema definition reference
	Items []any        // Element schemas for runtime validation
	Rest  any          // Rest schema for variadic elements
}

ZodArrayInternals contains the internal state for array schema

type ZodBase64 added in v0.3.0

type ZodBase64[T StringConstraint] struct{ *ZodString[T] }

ZodBase64 defines a schema for Base64 encoded strings.

func Base64 added in v0.3.0

func Base64(params ...any) *ZodBase64[string]

Base64 creates a Base64 encoded string validation schema. Supports custom error messages and schema parameters.

Base64()
Base64("custom error message")
Base64(core.SchemaParams{Description: "Base64 string"})

func Base64Ptr added in v0.3.0

func Base64Ptr(params ...any) *ZodBase64[*string]

Base64Ptr creates a Base64 encoded string validation schema for a pointer type.

func Base64Typed added in v0.3.0

func Base64Typed[T StringConstraint](params ...any) *ZodBase64[T]

Base64Typed creates a Base64 encoded string validation schema for a specific type.

func (*ZodBase64[T]) MustStrictParse added in v0.4.0

func (z *ZodBase64[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodBase64[T]) StrictParse added in v0.4.0

func (z *ZodBase64[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodBase64URL added in v0.3.0

type ZodBase64URL[T StringConstraint] struct{ *ZodString[T] }

ZodBase64URL defines a schema for Base64URL encoded strings.

func Base64URL added in v0.3.0

func Base64URL(params ...any) *ZodBase64URL[string]

Base64URL creates a Base64URL encoded string validation schema. Supports custom error messages and schema parameters.

Base64URL()
Base64URL("custom error message")
Base64URL(core.SchemaParams{Description: "Base64URL string"})

func Base64URLPtr added in v0.3.0

func Base64URLPtr(params ...any) *ZodBase64URL[*string]

Base64URLPtr creates a Base64URL encoded string validation schema for a pointer type.

func Base64URLTyped added in v0.3.0

func Base64URLTyped[T StringConstraint](params ...any) *ZodBase64URL[T]

Base64URLTyped creates a Base64URL encoded string validation schema for a specific type.

func (*ZodBase64URL[T]) MustStrictParse added in v0.4.0

func (z *ZodBase64URL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodBase64URL[T]) StrictParse added in v0.4.0

func (z *ZodBase64URL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodBigInt

type ZodBigInt[T BigIntegerConstraint] struct {
	// contains filtered or unexported fields
}

ZodBigInt represents a big.Int validation schema with type safety

func BigInt

func BigInt(params ...any) *ZodBigInt[*big.Int]

BigInt creates *big.Int schema with type-inference support

func BigIntPtr added in v0.3.0

func BigIntPtr(params ...any) *ZodBigInt[**big.Int]

BigIntPtr creates schema for **big.Int

func BigIntTyped added in v0.3.0

func BigIntTyped[T BigIntegerConstraint](params ...any) *ZodBigInt[T]

BigIntTyped is the generic constructor for big.Int schemas

func CoercedBigInt added in v0.2.1

func CoercedBigInt(params ...any) *ZodBigInt[*big.Int]

CoercedBigInt creates coerced *big.Int schema

func CoercedBigIntPtr added in v0.3.0

func CoercedBigIntPtr(params ...any) *ZodBigInt[**big.Int]

CoercedBigIntPtr creates coerced **big.Int schema

func (*ZodBigInt[T]) CloneFrom

func (z *ZodBigInt[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodBigInt[T]) Coerce

func (z *ZodBigInt[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for big.Int type conversion

func (*ZodBigInt[T]) Default

func (z *ZodBigInt[T]) Default(v *big.Int) *ZodBigInt[T]

Default preserves current generic type T

func (*ZodBigInt[T]) DefaultFunc

func (z *ZodBigInt[T]) DefaultFunc(fn func() *big.Int) *ZodBigInt[T]

DefaultFunc preserves current generic type T

func (*ZodBigInt[T]) Describe added in v0.5.4

func (z *ZodBigInt[T]) Describe(description string) *ZodBigInt[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodBigInt[T]) GetInternals

func (z *ZodBigInt[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodBigInt[T]) Gt

func (z *ZodBigInt[T]) Gt(value *big.Int, params ...any) *ZodBigInt[T]

Gt adds greater than validation (exclusive)

func (*ZodBigInt[T]) Gte

func (z *ZodBigInt[T]) Gte(value *big.Int, params ...any) *ZodBigInt[T]

Gte adds greater than or equal validation (inclusive)

func (*ZodBigInt[T]) IsNilable added in v0.3.0

func (z *ZodBigInt[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodBigInt[T]) IsOptional added in v0.3.0

func (z *ZodBigInt[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodBigInt[T]) Lt

func (z *ZodBigInt[T]) Lt(value *big.Int, params ...any) *ZodBigInt[T]

Lt adds less than validation (exclusive)

func (*ZodBigInt[T]) Lte

func (z *ZodBigInt[T]) Lte(value *big.Int, params ...any) *ZodBigInt[T]

Lte adds less than or equal validation (inclusive)

func (*ZodBigInt[T]) Max

func (z *ZodBigInt[T]) Max(maximum *big.Int, params ...any) *ZodBigInt[T]

Max adds maximum value validation

func (*ZodBigInt[T]) Meta added in v0.3.1

func (z *ZodBigInt[T]) Meta(meta core.GlobalMeta) *ZodBigInt[T]

Meta stores metadata for this bigint schema.

func (*ZodBigInt[T]) Min

func (z *ZodBigInt[T]) Min(minimum *big.Int, params ...any) *ZodBigInt[T]

Min adds minimum value validation

func (*ZodBigInt[T]) MultipleOf

func (z *ZodBigInt[T]) MultipleOf(value *big.Int, params ...any) *ZodBigInt[T]

MultipleOf adds multiple of validation

func (*ZodBigInt[T]) MustParse

func (z *ZodBigInt[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse validates the input value and panics on failure

func (*ZodBigInt[T]) MustStrictParse added in v0.4.0

func (z *ZodBigInt[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodBigInt[T]) Negative

func (z *ZodBigInt[T]) Negative(params ...any) *ZodBigInt[T]

Negative adds negative number validation (< 0)

func (*ZodBigInt[T]) Nilable

func (z *ZodBigInt[T]) Nilable() *ZodBigInt[**big.Int]

Nilable allows nil values, returns **big.Int

func (*ZodBigInt[T]) NonNegative

func (z *ZodBigInt[T]) NonNegative(params ...any) *ZodBigInt[T]

NonNegative adds non-negative number validation (>= 0)

func (*ZodBigInt[T]) NonOptional added in v0.3.0

func (z *ZodBigInt[T]) NonOptional() *ZodBigInt[*big.Int]

NonOptional removes optional flag and returns *big.Int constraint (single pointer). This is useful after Optional()/Nilable() when nil values should be disallowed again.

func (*ZodBigInt[T]) NonPositive

func (z *ZodBigInt[T]) NonPositive(params ...any) *ZodBigInt[T]

NonPositive adds non-positive number validation (<= 0)

func (*ZodBigInt[T]) Nullish

func (z *ZodBigInt[T]) Nullish() *ZodBigInt[**big.Int]

Nullish combines optional and nilable modifiers

func (*ZodBigInt[T]) Optional

func (z *ZodBigInt[T]) Optional() *ZodBigInt[**big.Int]

Optional always returns **big.Int for nullable semantics

func (*ZodBigInt[T]) Overwrite added in v0.3.0

func (z *ZodBigInt[T]) Overwrite(transform func(T) T, params ...any) *ZodBigInt[T]

Overwrite transforms big.Int value while keeping the same type

func (*ZodBigInt[T]) Parse

func (z *ZodBigInt[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety.

func (*ZodBigInt[T]) ParseAny added in v0.3.0

func (z *ZodBigInt[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodBigInt[T]) Pipe

func (z *ZodBigInt[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates validation pipeline to another schema

func (*ZodBigInt[T]) Positive

func (z *ZodBigInt[T]) Positive(params ...any) *ZodBigInt[T]

Positive adds positive number validation (> 0)

func (*ZodBigInt[T]) Prefault

func (z *ZodBigInt[T]) Prefault(v *big.Int) *ZodBigInt[T]

Prefault provides fallback values on validation failure

func (*ZodBigInt[T]) PrefaultFunc

func (z *ZodBigInt[T]) PrefaultFunc(fn func() *big.Int) *ZodBigInt[T]

PrefaultFunc keeps current generic type T.

func (*ZodBigInt[T]) Refine

func (z *ZodBigInt[T]) Refine(fn func(T) bool, params ...any) *ZodBigInt[T]

Refine applies type-safe validation with automatic type conversion

func (*ZodBigInt[T]) RefineAny

func (z *ZodBigInt[T]) RefineAny(fn func(any) bool, params ...any) *ZodBigInt[T]

RefineAny provides flexible validation without type conversion

func (*ZodBigInt[T]) StrictParse added in v0.4.0

func (z *ZodBigInt[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodBigInt[T]) Transform

func (z *ZodBigInt[T]) Transform(fn func(*big.Int, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates type-safe transformation pipeline

type ZodBigIntDef

type ZodBigIntDef struct {
	core.ZodTypeDef
}

ZodBigIntDef defines the configuration for big.Int validation

type ZodBigIntInternals

type ZodBigIntInternals struct {
	core.ZodTypeInternals
	Def *ZodBigIntDef // Schema definition
}

ZodBigIntInternals contains big.Int validator internal state

type ZodBool

type ZodBool[T BoolConstraint] struct {
	// contains filtered or unexported fields
}

ZodBool represents a boolean validation schema with type safety

func Bool

func Bool(params ...any) *ZodBool[bool]

Bool creates a bool schema following Zod TypeScript v4 pattern Usage:

Bool()                    // no parameters
Bool("custom error")      // string shorthand
Bool(SchemaParams{...})   // full parameters

func BoolPtr added in v0.3.0

func BoolPtr(params ...any) *ZodBool[*bool]

BoolPtr creates a schema for *bool

func BoolTyped added in v0.3.0

func BoolTyped[T BoolConstraint](params ...any) *ZodBool[T]

BoolTyped is the underlying generic function for creating boolean schemas allowing for explicit type parameterization

func CoercedBool added in v0.2.1

func CoercedBool(args ...any) *ZodBool[bool]

CoercedBool creates a bool schema with coercion enabled

func CoercedBoolPtr added in v0.3.0

func CoercedBoolPtr(args ...any) *ZodBool[*bool]

CoercedBoolPtr creates a *bool schema with coercion enabled

func (*ZodBool[T]) And added in v0.5.4

func (z *ZodBool[T]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Bool().And(gozod.Bool().Refine(func(b bool) bool { return b }))
result, _ := schema.Parse(true) // Must satisfy both constraints

func (*ZodBool[T]) Check added in v0.3.0

func (z *ZodBool[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodBool[T]

Check adds a custom validation function that can push multiple issues via ParsePayload.

func (*ZodBool[T]) CloneFrom

func (z *ZodBool[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodBool[T]) Coerce

func (z *ZodBool[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for boolean type conversion

func (*ZodBool[T]) Default

func (z *ZodBool[T]) Default(v bool) *ZodBool[T]

Default keeps the current generic type T.

func (*ZodBool[T]) DefaultFunc

func (z *ZodBool[T]) DefaultFunc(fn func() bool) *ZodBool[T]

DefaultFunc keeps the current generic type T.

func (*ZodBool[T]) Describe added in v0.5.4

func (z *ZodBool[T]) Describe(description string) *ZodBool[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodBool[T]) ExactOptional added in v0.5.4

func (z *ZodBool[T]) ExactOptional() *ZodBool[T]

ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional(), which accepts both absent keys AND nil values, ExactOptional() only accepts absent keys in object fields.

func (*ZodBool[T]) GetInternals

func (z *ZodBool[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodBool[T]) IsNilable added in v0.3.0

func (z *ZodBool[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodBool[T]) IsOptional added in v0.3.0

func (z *ZodBool[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodBool[T]) Meta added in v0.3.1

func (z *ZodBool[T]) Meta(meta core.GlobalMeta) *ZodBool[T]

Meta stores metadata for this boolean schema in the global registry.

func (*ZodBool[T]) MustParse

func (z *ZodBool[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error.

func (*ZodBool[T]) MustStrictParse added in v0.4.0

func (z *ZodBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodBool[T]) Nilable

func (z *ZodBool[T]) Nilable() *ZodBool[*bool]

Nilable always returns *bool because the value may be nil.

func (*ZodBool[T]) NonOptional added in v0.3.0

func (z *ZodBool[T]) NonOptional() *ZodBool[bool]

NonOptional removes the optional flag and forces return type to bool. It also sets internals.Type to ZodTypeNonOptional so that error reporting uses "nonoptional" rather than "bool" when nil is encountered.

func (*ZodBool[T]) Nullish

func (z *ZodBool[T]) Nullish() *ZodBool[*bool]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodBool[T]) Optional

func (z *ZodBool[T]) Optional() *ZodBool[*bool]

Optional always returns *bool because the optional value may be nil.

func (*ZodBool[T]) Or added in v0.5.4

func (z *ZodBool[T]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Bool().Or(gozod.String())
result, _ := schema.Parse(true)    // Accepts bool
result, _ = schema.Parse("hello")  // Accepts string

func (*ZodBool[T]) Overwrite added in v0.3.0

func (z *ZodBool[T]) Overwrite(transform func(T) T, params ...any) *ZodBool[T]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodBool[T]) Parse

func (z *ZodBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety.

func (*ZodBool[T]) ParseAny added in v0.3.0

func (z *ZodBool[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodBool[T]) Pipe

func (z *ZodBool[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

func (*ZodBool[T]) Prefault

func (z *ZodBool[T]) Prefault(v bool) *ZodBool[T]

Prefault keeps the current generic type T.

func (*ZodBool[T]) PrefaultFunc

func (z *ZodBool[T]) PrefaultFunc(fn func() bool) *ZodBool[T]

PrefaultFunc keeps the current generic type T.

func (*ZodBool[T]) Refine

func (z *ZodBool[T]) Refine(fn func(T) bool, params ...any) *ZodBool[T]

Refine applies a custom validation function that matches the schema's output type T.

func (*ZodBool[T]) RefineAny

func (z *ZodBool[T]) RefineAny(fn func(any) bool, params ...any) *ZodBool[T]

RefineAny adds flexible custom validation logic

func (*ZodBool[T]) StrictParse added in v0.4.0

func (z *ZodBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodBool[T]) Transform

func (z *ZodBool[T]) Transform(fn func(bool, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform applies a transformation function using the WrapFn pattern.

func (*ZodBool[T]) With added in v0.5.4

func (z *ZodBool[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodBool[T]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

This method exists for TypeScript Zod v4 API compatibility, where .with() is simply an alias for .check().

type ZodBoolDef

type ZodBoolDef struct {
	core.ZodTypeDef
}

ZodBoolDef defines the configuration for boolean validation

type ZodBoolInternals

type ZodBoolInternals struct {
	core.ZodTypeInternals
	Def *ZodBoolDef // Schema definition
}

ZodBoolInternals contains boolean validator internal state

type ZodCIDRv4

type ZodCIDRv4[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodCIDRv4 represents a CIDRv4 notation validation schema

func CIDRv4

func CIDRv4(params ...any) *ZodCIDRv4[string]

CIDRv4 creates CIDRv4 notation schema with type-inference support

func CIDRv4Ptr added in v0.3.0

func CIDRv4Ptr(params ...any) *ZodCIDRv4[*string]

CIDRv4Ptr creates schema for *string CIDRv4

func CIDRv4Typed added in v0.3.0

func CIDRv4Typed[T NetworkConstraint](params ...any) *ZodCIDRv4[T]

CIDRv4Typed is the generic constructor for CIDRv4 notation schemas

func CoercedCIDRv4 added in v0.3.0

func CoercedCIDRv4(params ...any) *ZodCIDRv4[string]

CoercedCIDRv4 creates coerced CIDRv4 schema that attempts string conversion

func (*ZodCIDRv4[T]) CloneFrom added in v0.3.0

func (z *ZodCIDRv4[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodCIDRv4[T]) Coerce added in v0.3.0

func (z *ZodCIDRv4[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface using coerce package

func (*ZodCIDRv4[T]) Default

func (z *ZodCIDRv4[T]) Default(v string) *ZodCIDRv4[T]

Default preserves current generic type T

func (*ZodCIDRv4[T]) DefaultFunc

func (z *ZodCIDRv4[T]) DefaultFunc(fn func() string) *ZodCIDRv4[T]

DefaultFunc preserves current generic type T

func (*ZodCIDRv4[T]) GetInternals

func (z *ZodCIDRv4[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodCIDRv4[T]) IsNilable added in v0.3.0

func (z *ZodCIDRv4[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodCIDRv4[T]) IsOptional added in v0.3.0

func (z *ZodCIDRv4[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodCIDRv4[T]) MustParse

func (z *ZodCIDRv4[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodCIDRv4[T]) MustStrictParse added in v0.4.0

func (z *ZodCIDRv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodCIDRv4[T]) Nilable

func (z *ZodCIDRv4[T]) Nilable() *ZodCIDRv4[*string]

Nilable allows nil values, returns pointer type

func (*ZodCIDRv4[T]) Nullish added in v0.3.0

func (z *ZodCIDRv4[T]) Nullish() *ZodCIDRv4[*string]

Nullish combines optional and nilable modifiers

func (*ZodCIDRv4[T]) Optional

func (z *ZodCIDRv4[T]) Optional() *ZodCIDRv4[*string]

Optional allows nil values, returns pointer type for nullable semantics

func (*ZodCIDRv4[T]) Parse

func (z *ZodCIDRv4[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns type-safe CIDRv4 notation using unified engine API

func (*ZodCIDRv4[T]) ParseAny added in v0.3.1

func (z *ZodCIDRv4[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input and returns any type (for runtime interface)

func (*ZodCIDRv4[T]) Pipe

func (z *ZodCIDRv4[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodCIDRv4[T]) Prefault

func (z *ZodCIDRv4[T]) Prefault(v string) *ZodCIDRv4[T]

Prefault provides fallback values on validation failure

func (*ZodCIDRv4[T]) PrefaultFunc

func (z *ZodCIDRv4[T]) PrefaultFunc(fn func() string) *ZodCIDRv4[T]

PrefaultFunc provides dynamic fallback values

func (*ZodCIDRv4[T]) Refine added in v0.3.0

func (z *ZodCIDRv4[T]) Refine(fn func(T) bool, params ...any) *ZodCIDRv4[T]

Refine adds type-safe custom validation logic

func (*ZodCIDRv4[T]) RefineAny

func (z *ZodCIDRv4[T]) RefineAny(fn func(any) bool, params ...any) *ZodCIDRv4[T]

RefineAny adds flexible custom validation logic

func (*ZodCIDRv4[T]) StrictParse added in v0.4.0

func (z *ZodCIDRv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodCIDRv4[T]) Transform

func (z *ZodCIDRv4[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates type-safe transformation using WrapFn pattern

type ZodCIDRv4Def

type ZodCIDRv4Def struct {
	core.ZodTypeDef
}

ZodCIDRv4Def defines the configuration for CIDRv4 notation validation

type ZodCIDRv4Internals

type ZodCIDRv4Internals struct {
	core.ZodTypeInternals
	Def *ZodCIDRv4Def // Schema definition
}

ZodCIDRv4Internals contains CIDRv4 validator internal state

type ZodCIDRv6

type ZodCIDRv6[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodCIDRv6 represents a CIDRv6 notation validation schema

func CIDRv6

func CIDRv6(params ...any) *ZodCIDRv6[string]

CIDRv6 creates CIDRv6 notation schema with type-inference support

func CIDRv6Ptr added in v0.3.0

func CIDRv6Ptr(params ...any) *ZodCIDRv6[*string]

CIDRv6Ptr creates schema for *string CIDRv6

func CIDRv6Typed added in v0.3.0

func CIDRv6Typed[T NetworkConstraint](params ...any) *ZodCIDRv6[T]

CIDRv6Typed is the generic constructor for CIDRv6 notation schemas

func CoercedCIDRv6 added in v0.3.0

func CoercedCIDRv6(params ...any) *ZodCIDRv6[string]

CoercedCIDRv6 creates coerced CIDRv6 schema that attempts string conversion

func (*ZodCIDRv6[T]) CloneFrom added in v0.3.0

func (z *ZodCIDRv6[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodCIDRv6[T]) Coerce added in v0.3.0

func (z *ZodCIDRv6[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface using coerce package

func (*ZodCIDRv6[T]) Default

func (z *ZodCIDRv6[T]) Default(v string) *ZodCIDRv6[T]

Default preserves current generic type T

func (*ZodCIDRv6[T]) DefaultFunc

func (z *ZodCIDRv6[T]) DefaultFunc(fn func() string) *ZodCIDRv6[T]

DefaultFunc preserves current generic type T

func (*ZodCIDRv6[T]) GetInternals

func (z *ZodCIDRv6[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodCIDRv6[T]) IsNilable added in v0.3.0

func (z *ZodCIDRv6[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodCIDRv6[T]) IsOptional added in v0.3.0

func (z *ZodCIDRv6[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodCIDRv6[T]) MustParse

func (z *ZodCIDRv6[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodCIDRv6[T]) MustStrictParse added in v0.4.0

func (z *ZodCIDRv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodCIDRv6[T]) Nilable

func (z *ZodCIDRv6[T]) Nilable() *ZodCIDRv6[*string]

Nilable allows nil values, returns pointer type

func (*ZodCIDRv6[T]) Nullish added in v0.3.0

func (z *ZodCIDRv6[T]) Nullish() *ZodCIDRv6[*string]

Nullish combines optional and nilable modifiers

func (*ZodCIDRv6[T]) Optional

func (z *ZodCIDRv6[T]) Optional() *ZodCIDRv6[*string]

Optional allows nil values, returns pointer type for nullable semantics

func (*ZodCIDRv6[T]) Parse

func (z *ZodCIDRv6[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns type-safe CIDRv6 notation using unified engine API

func (*ZodCIDRv6[T]) ParseAny added in v0.3.1

func (z *ZodCIDRv6[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input and returns any type (for runtime interface)

func (*ZodCIDRv6[T]) Pipe

func (z *ZodCIDRv6[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodCIDRv6[T]) Prefault added in v0.3.0

func (z *ZodCIDRv6[T]) Prefault(v string) *ZodCIDRv6[T]

Prefault provides fallback values on validation failure

func (*ZodCIDRv6[T]) PrefaultFunc added in v0.3.0

func (z *ZodCIDRv6[T]) PrefaultFunc(fn func() string) *ZodCIDRv6[T]

PrefaultFunc provides dynamic fallback values

func (*ZodCIDRv6[T]) Refine added in v0.3.0

func (z *ZodCIDRv6[T]) Refine(fn func(T) bool, params ...any) *ZodCIDRv6[T]

Refine adds type-safe custom validation logic

func (*ZodCIDRv6[T]) RefineAny

func (z *ZodCIDRv6[T]) RefineAny(fn func(any) bool, params ...any) *ZodCIDRv6[T]

RefineAny adds flexible custom validation logic

func (*ZodCIDRv6[T]) StrictParse added in v0.4.0

func (z *ZodCIDRv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodCIDRv6[T]) Transform

func (z *ZodCIDRv6[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates type-safe transformation using WrapFn pattern

type ZodCIDRv6Def

type ZodCIDRv6Def struct {
	core.ZodTypeDef
}

ZodCIDRv6Def defines the configuration for CIDRv6 notation validation

type ZodCIDRv6Internals

type ZodCIDRv6Internals struct {
	core.ZodTypeInternals
	Def *ZodCIDRv6Def // Schema definition
}

ZodCIDRv6Internals contains CIDRv6 validator internal state

type ZodCUID added in v0.3.0

type ZodCUID[T StringConstraint] struct{ *ZodString[T] }

func Cuid added in v0.3.0

func Cuid(params ...any) *ZodCUID[string]

func CuidPtr added in v0.3.0

func CuidPtr(params ...any) *ZodCUID[*string]

func (*ZodCUID[T]) MustStrictParse added in v0.4.0

func (z *ZodCUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodCUID[T]) StrictParse added in v0.4.0

func (z *ZodCUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodCUID2 added in v0.3.0

type ZodCUID2[T StringConstraint] struct{ *ZodString[T] }

func Cuid2 added in v0.3.0

func Cuid2(params ...any) *ZodCUID2[string]

func Cuid2Ptr added in v0.3.0

func Cuid2Ptr(params ...any) *ZodCUID2[*string]

func (*ZodCUID2[T]) MustStrictParse added in v0.4.0

func (z *ZodCUID2[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodCUID2[T]) StrictParse added in v0.4.0

func (z *ZodCUID2[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodComplex

type ZodComplex[T ComplexConstraint] struct {
	// contains filtered or unexported fields
}

ZodComplex represents a generic complex number validation schema

func CoercedComplex added in v0.3.0

func CoercedComplex(params ...any) *ZodComplex[complex128]

CoercedComplex creates coerced complex128 schema (default)

func CoercedComplex64 added in v0.2.1

func CoercedComplex64(params ...any) *ZodComplex[complex64]

CoercedComplex64 creates coerced complex64 schema

func CoercedComplex64Ptr added in v0.3.0

func CoercedComplex64Ptr(params ...any) *ZodComplex[*complex64]

CoercedComplex64Ptr creates coerced *complex64 schema

func CoercedComplex128 added in v0.2.1

func CoercedComplex128(params ...any) *ZodComplex[complex128]

CoercedComplex128 creates coerced complex128 schema

func CoercedComplex128Ptr added in v0.3.0

func CoercedComplex128Ptr(params ...any) *ZodComplex[*complex128]

CoercedComplex128Ptr creates coerced *complex128 schema

func CoercedComplexPtr added in v0.3.0

func CoercedComplexPtr(params ...any) *ZodComplex[*complex128]

CoercedComplexPtr creates coerced *complex128 schema (default)

func Complex

func Complex(params ...any) *ZodComplex[complex128]

Complex creates complex128 schema (default)

func Complex64

func Complex64(params ...any) *ZodComplex[complex64]

Complex64 creates complex64 schema

func Complex64Ptr added in v0.3.0

func Complex64Ptr(params ...any) *ZodComplex[*complex64]

Complex64Ptr creates schema for *complex64

func Complex128

func Complex128(params ...any) *ZodComplex[complex128]

Complex128 creates complex128 schema

func Complex128Ptr added in v0.3.0

func Complex128Ptr(params ...any) *ZodComplex[*complex128]

Complex128Ptr creates schema for *complex128

func ComplexPtr added in v0.3.0

func ComplexPtr(params ...any) *ZodComplex[*complex128]

ComplexPtr creates schema for *complex128 (default)

func ComplexTyped added in v0.3.0

func ComplexTyped[T ComplexConstraint](params ...any) *ZodComplex[T]

ComplexTyped creates a generic complex schema with automatic type inference. It automatically determines the appropriate type code based on the generic type parameter. Usage: ComplexTyped[complex64](), ComplexTyped[complex128](), ComplexTyped[*complex64](), etc.

func (*ZodComplex[T]) CloneFrom

func (z *ZodComplex[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodComplex[T]) Coerce

func (z *ZodComplex[T]) Coerce(input any) (any, bool)

Coerce attempts to coerce input to target complex type using coerce package

func (*ZodComplex[T]) Default

func (z *ZodComplex[T]) Default(v complex128) *ZodComplex[T]

Default preserves current generic type T

func (*ZodComplex[T]) DefaultFunc

func (z *ZodComplex[T]) DefaultFunc(fn func() complex128) *ZodComplex[T]

DefaultFunc preserves current generic type T

func (*ZodComplex[T]) Describe added in v0.5.4

func (z *ZodComplex[T]) Describe(description string) *ZodComplex[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodComplex[T]) Finite added in v0.3.0

func (z *ZodComplex[T]) Finite(params ...any) *ZodComplex[T]

Finite adds finite validation for complex numbers (no infinite components)

func (*ZodComplex[T]) GetInternals

func (z *ZodComplex[T]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodComplex[T]) Gt

func (z *ZodComplex[T]) Gt(value float64, params ...any) *ZodComplex[T]

Gt adds greater than validation for complex magnitude (exclusive)

func (*ZodComplex[T]) Gte

func (z *ZodComplex[T]) Gte(value float64, params ...any) *ZodComplex[T]

Gte adds greater than or equal validation for complex magnitude (inclusive)

func (*ZodComplex[T]) IsNilable added in v0.3.0

func (z *ZodComplex[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodComplex[T]) IsOptional added in v0.3.0

func (z *ZodComplex[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodComplex[T]) Lt

func (z *ZodComplex[T]) Lt(value float64, params ...any) *ZodComplex[T]

Lt adds less than validation for complex magnitude (exclusive)

func (*ZodComplex[T]) Lte

func (z *ZodComplex[T]) Lte(value float64, params ...any) *ZodComplex[T]

Lte adds less than or equal validation for complex magnitude (inclusive)

func (*ZodComplex[T]) Max

func (z *ZodComplex[T]) Max(maximum float64, params ...any) *ZodComplex[T]

Max adds maximum magnitude validation for complex numbers

func (*ZodComplex[T]) Meta added in v0.3.1

func (z *ZodComplex[T]) Meta(meta core.GlobalMeta) *ZodComplex[T]

Meta stores metadata for this complex number schema.

func (*ZodComplex[T]) Min

func (z *ZodComplex[T]) Min(minimum float64, params ...any) *ZodComplex[T]

Min adds minimum magnitude validation for complex numbers

func (*ZodComplex[T]) MustParse

func (z *ZodComplex[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse validates the input value and panics on failure

func (*ZodComplex[T]) MustStrictParse added in v0.4.0

func (z *ZodComplex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodComplex[T]) Negative

func (z *ZodComplex[T]) Negative(params ...any) *ZodComplex[T]

Negative adds negative validation (< 0) - validates real part for complex numbers

func (*ZodComplex[T]) Nilable

func (z *ZodComplex[T]) Nilable() *ZodComplex[*complex128]

Nilable allows nil values, returns pointer type

func (*ZodComplex[T]) NonNegative

func (z *ZodComplex[T]) NonNegative(params ...any) *ZodComplex[T]

NonNegative adds non-negative validation (>= 0) for complex magnitude

func (*ZodComplex[T]) NonPositive

func (z *ZodComplex[T]) NonPositive(params ...any) *ZodComplex[T]

NonPositive adds non-positive validation (<= 0) for complex magnitude

func (*ZodComplex[T]) Nullish

func (z *ZodComplex[T]) Nullish() *ZodComplex[*complex128]

Nullish combines optional and nilable modifiers

func (*ZodComplex[T]) Optional

func (z *ZodComplex[T]) Optional() *ZodComplex[*complex128]

Optional always returns *complex128 for nullable semantics

func (*ZodComplex[T]) Overwrite added in v0.3.0

func (z *ZodComplex[T]) Overwrite(transform func(T) T, params ...any) *ZodComplex[T]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodComplex[T]) Parse

func (z *ZodComplex[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse validates input using unified ParsePrimitive API

func (*ZodComplex[T]) ParseAny added in v0.3.0

func (z *ZodComplex[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodComplex[T]) Pipe

func (z *ZodComplex[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using the WrapFn pattern

func (*ZodComplex[T]) Positive

func (z *ZodComplex[T]) Positive(params ...any) *ZodComplex[T]

Positive adds positive magnitude validation (> 0) for complex numbers

func (*ZodComplex[T]) Prefault

func (z *ZodComplex[T]) Prefault(v complex128) *ZodComplex[T]

Prefault provides fallback values on validation failure

func (*ZodComplex[T]) PrefaultFunc

func (z *ZodComplex[T]) PrefaultFunc(fn func() complex128) *ZodComplex[T]

PrefaultFunc keeps the current generic type T.

func (*ZodComplex[T]) Refine

func (z *ZodComplex[T]) Refine(fn func(T) bool, params ...any) *ZodComplex[T]

Refine applies type-safe validation with automatic type conversion

func (*ZodComplex[T]) RefineAny

func (z *ZodComplex[T]) RefineAny(fn func(any) bool, params ...any) *ZodComplex[T]

RefineAny provides flexible validation without type conversion

func (*ZodComplex[T]) StrictParse added in v0.4.0

func (z *ZodComplex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodComplex[T]) Transform

func (z *ZodComplex[T]) Transform(fn func(complex128, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using the WrapFn pattern

type ZodComplexDef

type ZodComplexDef struct {
	core.ZodTypeDef
}

ZodComplexDef defines the schema definition for complex number validation

type ZodComplexInternals

type ZodComplexInternals struct {
	core.ZodTypeInternals
	Def *ZodComplexDef // Schema definition reference
}

ZodComplexInternals contains the internal state for complex schema

type ZodDiscriminatedUnion

type ZodDiscriminatedUnion[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodDiscriminatedUnion represents a discriminated union validation schema with dual generic parameters T = base type (any), R = constraint type (any or *any)

func DiscriminatedUnion

func DiscriminatedUnion(discriminator string, options []any, args ...any) *ZodDiscriminatedUnion[any, any]

DiscriminatedUnion creates discriminated union schema that accepts one of the specified object types - returns value constraint

func DiscriminatedUnionPtr added in v0.3.0

func DiscriminatedUnionPtr(discriminator string, options []any, args ...any) *ZodDiscriminatedUnion[any, *any]

DiscriminatedUnionPtr creates discriminated union schema that accepts one of the specified object types - returns pointer constraint

func DiscriminatedUnionTyped added in v0.3.0

func DiscriminatedUnionTyped[T any, R any](discriminator string, options []any, args ...any) *ZodDiscriminatedUnion[T, R]

DiscriminatedUnionTyped creates typed discriminated union schema with generic constraints

func (*ZodDiscriminatedUnion[T, R]) CloneFrom

func (z *ZodDiscriminatedUnion[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodDiscriminatedUnion[T, R]) Default

func (z *ZodDiscriminatedUnion[T, R]) Default(v T) *ZodDiscriminatedUnion[T, R]

Default preserves current constraint type R

func (*ZodDiscriminatedUnion[T, R]) DefaultFunc

func (z *ZodDiscriminatedUnion[T, R]) DefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]

DefaultFunc preserves current constraint type R

func (*ZodDiscriminatedUnion[T, R]) Describe added in v0.5.4

func (z *ZodDiscriminatedUnion[T, R]) Describe(description string) *ZodDiscriminatedUnion[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodDiscriminatedUnion[T, R]) Discriminator

func (z *ZodDiscriminatedUnion[T, R]) Discriminator() string

Discriminator returns the discriminator field name

func (*ZodDiscriminatedUnion[T, R]) DiscriminatorMap added in v0.3.0

func (z *ZodDiscriminatedUnion[T, R]) DiscriminatorMap() map[any]core.ZodSchema

DiscriminatorMap returns the discriminator value to schema mapping

func (*ZodDiscriminatedUnion[T, R]) GetInternals

func (z *ZodDiscriminatedUnion[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodDiscriminatedUnion[T, R]) IsNilable added in v0.3.0

func (z *ZodDiscriminatedUnion[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodDiscriminatedUnion[T, R]) IsOptional added in v0.3.0

func (z *ZodDiscriminatedUnion[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodDiscriminatedUnion[T, R]) Meta added in v0.3.1

func (z *ZodDiscriminatedUnion[T, R]) Meta(meta core.GlobalMeta) *ZodDiscriminatedUnion[T, R]

Meta stores metadata for this discriminated union schema.

func (*ZodDiscriminatedUnion[T, R]) MustParse

func (z *ZodDiscriminatedUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodDiscriminatedUnion[T, R]) MustStrictParse added in v0.4.0

func (z *ZodDiscriminatedUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodDiscriminatedUnion[T, R]) Nilable

func (z *ZodDiscriminatedUnion[T, R]) Nilable() *ZodDiscriminatedUnion[T, *T]

Nilable allows nil values and returns pointer constraint

func (*ZodDiscriminatedUnion[T, R]) Nullish added in v0.3.0

func (z *ZodDiscriminatedUnion[T, R]) Nullish() *ZodDiscriminatedUnion[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodDiscriminatedUnion[T, R]) Optional

func (z *ZodDiscriminatedUnion[T, R]) Optional() *ZodDiscriminatedUnion[T, *T]

Optional creates optional discriminated union schema that returns pointer constraint

func (*ZodDiscriminatedUnion[T, R]) Options

func (z *ZodDiscriminatedUnion[T, R]) Options() []core.ZodSchema

Options returns all union member schemas

func (*ZodDiscriminatedUnion[T, R]) Parse

func (z *ZodDiscriminatedUnion[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using discriminated union logic with direct validation approach

func (*ZodDiscriminatedUnion[T, R]) ParseAny added in v0.3.0

func (z *ZodDiscriminatedUnion[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodDiscriminatedUnion[T, R]) Pipe

func (z *ZodDiscriminatedUnion[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates validation pipeline to another schema using WrapFn pattern

func (*ZodDiscriminatedUnion[T, R]) Prefault

func (z *ZodDiscriminatedUnion[T, R]) Prefault(v T) *ZodDiscriminatedUnion[T, R]

Prefault provides fallback values on validation failure

func (*ZodDiscriminatedUnion[T, R]) PrefaultFunc

func (z *ZodDiscriminatedUnion[T, R]) PrefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]

PrefaultFunc keeps current generic type R.

func (*ZodDiscriminatedUnion[T, R]) Refine

func (z *ZodDiscriminatedUnion[T, R]) Refine(fn func(R) bool, params ...any) *ZodDiscriminatedUnion[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodDiscriminatedUnion[T, R]) RefineAny

func (z *ZodDiscriminatedUnion[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodDiscriminatedUnion[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodDiscriminatedUnion[T, R]) StrictParse added in v0.4.0

func (z *ZodDiscriminatedUnion[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodDiscriminatedUnion[T, R]) Transform

func (z *ZodDiscriminatedUnion[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates type-safe transformation pipeline using WrapFn pattern

type ZodDiscriminatedUnionDef

type ZodDiscriminatedUnionDef struct {
	core.ZodTypeDef
	Discriminator string           // The discriminator field name
	Options       []core.ZodSchema // Union member schemas using unified interface
}

ZodDiscriminatedUnionDef defines the configuration for discriminated union validation

type ZodDiscriminatedUnionInternals

type ZodDiscriminatedUnionInternals struct {
	core.ZodTypeInternals
	Def           *ZodDiscriminatedUnionDef // Schema definition reference
	Discriminator string                    // The discriminator field name
	Options       []core.ZodSchema          // Union member schemas for runtime validation
	DiscMap       map[any]core.ZodSchema    // Discriminator value to schema mapping
}

ZodDiscriminatedUnionInternals contains discriminated union validator internal state

type ZodE164 added in v0.5.4

type ZodE164[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodE164 represents an E.164 phone number validation schema

func E164 added in v0.5.4

func E164(params ...any) *ZodE164[string]

E164 creates an E.164 phone number schema

func E164Ptr added in v0.5.4

func E164Ptr(params ...any) *ZodE164[*string]

E164Ptr creates an E.164 phone number schema for pointer types

func E164Typed added in v0.5.4

func E164Typed[T NetworkConstraint](params ...any) *ZodE164[T]

E164Typed creates an E.164 phone number schema with specific type

func (*ZodE164[T]) And added in v0.5.4

func (z *ZodE164[T]) And(other any) *ZodIntersection[any, any]

func (*ZodE164[T]) Coerce added in v0.5.4

func (z *ZodE164[T]) Coerce(input any) (any, bool)

func (*ZodE164[T]) Default added in v0.5.4

func (z *ZodE164[T]) Default(v string) *ZodE164[T]

func (*ZodE164[T]) Describe added in v0.5.4

func (z *ZodE164[T]) Describe(description string) *ZodE164[T]

func (*ZodE164[T]) GetInternals added in v0.5.4

func (z *ZodE164[T]) GetInternals() *core.ZodTypeInternals

func (*ZodE164[T]) IsNilable added in v0.5.4

func (z *ZodE164[T]) IsNilable() bool

func (*ZodE164[T]) IsOptional added in v0.5.4

func (z *ZodE164[T]) IsOptional() bool

func (*ZodE164[T]) MustParse added in v0.5.4

func (z *ZodE164[T]) MustParse(input any, ctx ...*core.ParseContext) T

func (*ZodE164[T]) MustStrictParse added in v0.5.4

func (z *ZodE164[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

func (*ZodE164[T]) Nilable added in v0.5.4

func (z *ZodE164[T]) Nilable() *ZodE164[*string]

func (*ZodE164[T]) Optional added in v0.5.4

func (z *ZodE164[T]) Optional() *ZodE164[*string]

func (*ZodE164[T]) Or added in v0.5.4

func (z *ZodE164[T]) Or(other any) *ZodUnion[any, any]

func (*ZodE164[T]) Parse added in v0.5.4

func (z *ZodE164[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

func (*ZodE164[T]) ParseAny added in v0.5.4

func (z *ZodE164[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

func (*ZodE164[T]) StrictParse added in v0.5.4

func (z *ZodE164[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

type ZodE164Def added in v0.5.4

type ZodE164Def struct {
	core.ZodTypeDef
}

ZodE164Def defines the configuration for E.164 phone number validation

type ZodE164Internals added in v0.5.4

type ZodE164Internals struct {
	core.ZodTypeInternals
	Def *ZodE164Def
}

ZodE164Internals contains E.164 validator internal state

func (*ZodE164Internals) Clone added in v0.5.4

Clone creates a deep copy of internals

type ZodEmail added in v0.3.0

type ZodEmail[T EmailConstraint] struct{ *ZodString[T] }

func Email added in v0.3.0

func Email(params ...any) *ZodEmail[string]

func EmailPtr added in v0.3.0

func EmailPtr(params ...any) *ZodEmail[*string]

func EmailTyped added in v0.3.0

func EmailTyped[T EmailConstraint](params ...any) *ZodEmail[T]

EmailTyped creates an email validation schema with specific type

func (*ZodEmail[T]) Browser added in v0.3.0

func (z *ZodEmail[T]) Browser(params ...any) *ZodEmail[T]

func (*ZodEmail[T]) GetInternals added in v0.3.0

func (z *ZodEmail[T]) GetInternals() *core.ZodTypeInternals

GetInternals proxies to the embedded string schema.

func (*ZodEmail[T]) Html5 added in v0.3.0

func (z *ZodEmail[T]) Html5(params ...any) *ZodEmail[T]

func (*ZodEmail[T]) MustStrictParse added in v0.4.0

func (z *ZodEmail[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodEmail[T]) Nilable added in v0.3.0

func (z *ZodEmail[T]) Nilable() *ZodEmail[*string]

func (*ZodEmail[T]) Nullish added in v0.3.0

func (z *ZodEmail[T]) Nullish() *ZodEmail[*string]

func (*ZodEmail[T]) Optional added in v0.3.0

func (z *ZodEmail[T]) Optional() *ZodEmail[*string]

func (*ZodEmail[T]) Rfc5322 added in v0.3.0

func (z *ZodEmail[T]) Rfc5322(params ...any) *ZodEmail[T]

func (*ZodEmail[T]) StrictParse added in v0.4.0

func (z *ZodEmail[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

func (*ZodEmail[T]) Unicode added in v0.3.0

func (z *ZodEmail[T]) Unicode(params ...any) *ZodEmail[T]

type ZodEmoji added in v0.3.0

type ZodEmoji[T StringConstraint] struct{ *ZodString[T] }

func Emoji added in v0.3.0

func Emoji(params ...any) *ZodEmoji[string]

func EmojiPtr added in v0.3.0

func EmojiPtr(params ...any) *ZodEmoji[*string]

func (*ZodEmoji[T]) MustStrictParse added in v0.4.0

func (z *ZodEmoji[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodEmoji[T]) StrictParse added in v0.4.0

func (z *ZodEmoji[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodEnum

type ZodEnum[T comparable, R any] struct {
	// contains filtered or unexported fields
}

ZodEnum represents a type-safe enum validation schema with unified constraint T is the base comparable type, R is the constraint type (T | *T)

func Enum

func Enum[T comparable](values ...T) *ZodEnum[T, T]

Enum creates enum schema from values with type-inference support

func EnumMap

func EnumMap[T comparable](entries map[string]T, params ...any) *ZodEnum[T, T]

EnumMap creates enum schema from key-value mapping

func EnumMapPtr added in v0.3.0

func EnumMapPtr[T comparable](entries map[string]T, params ...any) *ZodEnum[T, *T]

EnumMapPtr creates pointer-capable enum schema from key-value mapping

func EnumMapTyped added in v0.3.0

func EnumMapTyped[T comparable, R any](entries map[string]T, args ...any) *ZodEnum[T, R]

EnumMapTyped is the generic constructor for enum schemas from mapping

func EnumPtr added in v0.3.0

func EnumPtr[T comparable](values ...T) *ZodEnum[T, *T]

EnumPtr creates pointer-capable enum schema from values

func EnumSlice

func EnumSlice[T comparable](values []T) *ZodEnum[T, T]

EnumSlice creates enum schema from slice of values

func EnumSlicePtr added in v0.3.0

func EnumSlicePtr[T comparable](values []T) *ZodEnum[T, *T]

EnumSlicePtr creates pointer-capable enum schema from slice of values

func (*ZodEnum[T, R]) CloneFrom added in v0.3.0

func (z *ZodEnum[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodEnum[T, R]) Default

func (z *ZodEnum[T, R]) Default(v T) *ZodEnum[T, R]

Default keeps the current generic constraint type R.

func (*ZodEnum[T, R]) DefaultFunc

func (z *ZodEnum[T, R]) DefaultFunc(fn func() T) *ZodEnum[T, R]

DefaultFunc keeps the current generic constraint type R.

func (*ZodEnum[T, R]) Describe added in v0.5.4

func (z *ZodEnum[T, R]) Describe(description string) *ZodEnum[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodEnum[T, R]) Enum

func (z *ZodEnum[T, R]) Enum() map[string]T

Enum returns the enum key-value mapping

func (*ZodEnum[T, R]) Exclude

func (z *ZodEnum[T, R]) Exclude(keys []string, params ...any) *ZodEnum[T, R]

Exclude creates a sub-enum excluding specified keys Non-existent keys are silently ignored to maintain fluent interface design

func (*ZodEnum[T, R]) Extract

func (z *ZodEnum[T, R]) Extract(keys []string, params ...any) *ZodEnum[T, R]

Extract creates a sub-enum with specified keys Non-existent keys are silently ignored to maintain fluent interface design

func (*ZodEnum[T, R]) GetInternals

func (z *ZodEnum[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodEnum[T, R]) IsNilable added in v0.3.0

func (z *ZodEnum[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodEnum[T, R]) IsOptional added in v0.3.0

func (z *ZodEnum[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodEnum[T, R]) Meta added in v0.3.1

func (z *ZodEnum[T, R]) Meta(meta core.GlobalMeta) *ZodEnum[T, R]

Meta stores metadata for this enum schema.

func (*ZodEnum[T, R]) MustParse

func (z *ZodEnum[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodEnum[T, R]) MustStrictParse added in v0.4.0

func (z *ZodEnum[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodEnum[T, R]) Nilable

func (z *ZodEnum[T, R]) Nilable() *ZodEnum[T, *T]

Nilable always returns *T constraint because the value may be nil.

func (*ZodEnum[T, R]) Nullish

func (z *ZodEnum[T, R]) Nullish() *ZodEnum[T, *T]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodEnum[T, R]) Optional

func (z *ZodEnum[T, R]) Optional() *ZodEnum[T, *T]

Optional always returns *T constraint because the optional value may be nil.

func (*ZodEnum[T, R]) Options

func (z *ZodEnum[T, R]) Options() []T

Options returns all possible enum values

func (*ZodEnum[T, R]) Parse

func (z *ZodEnum[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using enum-specific parsing logic

func (*ZodEnum[T, R]) ParseAny added in v0.3.0

func (z *ZodEnum[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodEnum[T, R]) Pipe

func (z *ZodEnum[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern.

func (*ZodEnum[T, R]) Prefault

func (z *ZodEnum[T, R]) Prefault(v T) *ZodEnum[T, R]

Prefault provides fallback values on validation failure

func (*ZodEnum[T, R]) PrefaultFunc

func (z *ZodEnum[T, R]) PrefaultFunc(fn func() T) *ZodEnum[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodEnum[T, R]) Refine

func (z *ZodEnum[T, R]) Refine(fn func(R) bool, params ...any) *ZodEnum[T, R]

Refine applies type-safe validation that matches the schema's output type R. The callback will be executed even when the value is nil (for *T schemas) to align with Zod v4 semantics.

func (*ZodEnum[T, R]) RefineAny

func (z *ZodEnum[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodEnum[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodEnum[T, R]) StrictParse added in v0.4.0

func (z *ZodEnum[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodEnum[T, R]) Transform

func (z *ZodEnum[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern.

type ZodEnumDef

type ZodEnumDef[T comparable] struct {
	core.ZodTypeDef
	Entries map[string]T // Enum key-value mapping
}

ZodEnumDef defines the schema definition for enum validation

type ZodEnumInternals

type ZodEnumInternals[T comparable] struct {
	core.ZodTypeInternals
	Def     *ZodEnumDef[T] // Schema definition reference
	Entries map[string]T   // Enum key-value mapping
	Values  map[T]struct{} // Set of valid values for fast lookup
	Pattern *regexp.Regexp // Compiled regex pattern for validation
}

ZodEnumInternals contains the internal state for enum schema

type ZodFile

type ZodFile[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodFile represents a file validation schema with constraint types T and R

func File

func File(params ...any) *ZodFile[any, any]

File creates a new file schema

func FilePtr added in v0.3.0

func FilePtr(params ...any) *ZodFile[any, *any]

FilePtr creates a new file schema with pointer constraint

func FileTyped added in v0.3.0

func FileTyped[T any, R any](params ...any) *ZodFile[T, R]

FileTyped creates a new file schema with specific constraint types

func (*ZodFile[T, R]) CloneFrom

func (z *ZodFile[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodFile[T, R]) Default

func (z *ZodFile[T, R]) Default(v T) *ZodFile[T, R]

Default sets a default value for the file type

func (*ZodFile[T, R]) DefaultFunc

func (z *ZodFile[T, R]) DefaultFunc(fn func() T) *ZodFile[T, R]

DefaultFunc sets a default function for the file type

func (*ZodFile[T, R]) Describe added in v0.5.4

func (z *ZodFile[T, R]) Describe(description string) *ZodFile[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodFile[T, R]) GetInternals

func (z *ZodFile[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state for interface compatibility

func (*ZodFile[T, R]) IsNilable added in v0.3.0

func (z *ZodFile[T, R]) IsNilable() bool

IsNilable returns whether the file type is nilable

func (*ZodFile[T, R]) IsOptional added in v0.3.0

func (z *ZodFile[T, R]) IsOptional() bool

IsOptional returns whether the file type is optional

func (*ZodFile[T, R]) Max

func (z *ZodFile[T, R]) Max(maximum int64, params ...any) *ZodFile[T, R]

Max sets maximum file size validation

func (*ZodFile[T, R]) Meta added in v0.3.1

func (z *ZodFile[T, R]) Meta(meta core.GlobalMeta) *ZodFile[T, R]

Meta adds metadata to the file type

func (*ZodFile[T, R]) Mime

func (z *ZodFile[T, R]) Mime(mimeTypes []string, params ...any) *ZodFile[T, R]

Mime sets MIME type validation

func (*ZodFile[T, R]) Min

func (z *ZodFile[T, R]) Min(minimum int64, params ...any) *ZodFile[T, R]

Min sets minimum file size validation

func (*ZodFile[T, R]) MustParse

func (z *ZodFile[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse is the variant that panics on error

func (*ZodFile[T, R]) MustStrictParse added in v0.4.0

func (z *ZodFile[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodFile[T, R]) Nilable

func (z *ZodFile[T, R]) Nilable() *ZodFile[T, *T]

Nilable makes the file type nilable and returns pointer constraint

func (*ZodFile[T, R]) Nullish

func (z *ZodFile[T, R]) Nullish() *ZodFile[T, *T]

Nullish makes the file type both optional and nilable

func (*ZodFile[T, R]) Optional

func (z *ZodFile[T, R]) Optional() *ZodFile[T, *T]

Optional makes the file type optional and returns pointer constraint

func (*ZodFile[T, R]) Overwrite added in v0.3.0

func (z *ZodFile[T, R]) Overwrite(transform func(R) R, params ...any) *ZodFile[T, R]

Overwrite applies a transformation function to the file value

func (*ZodFile[T, R]) Parse

func (z *ZodFile[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse returns a validated file using direct validation for better performance

func (*ZodFile[T, R]) ParseAny added in v0.3.0

func (z *ZodFile[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodFile[T, R]) Pipe

func (z *ZodFile[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline to another schema

func (*ZodFile[T, R]) Prefault

func (z *ZodFile[T, R]) Prefault(v T) *ZodFile[T, R]

Prefault sets a prefault value for the file type

func (*ZodFile[T, R]) PrefaultFunc

func (z *ZodFile[T, R]) PrefaultFunc(fn func() T) *ZodFile[T, R]

PrefaultFunc sets a prefault function for the file type

func (*ZodFile[T, R]) Refine

func (z *ZodFile[T, R]) Refine(fn func(R) bool, params ...any) *ZodFile[T, R]

Refine adds custom validation logic

func (*ZodFile[T, R]) RefineAny

func (z *ZodFile[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodFile[T, R]

RefineAny adds custom validation logic with any type

func (*ZodFile[T, R]) Size

func (z *ZodFile[T, R]) Size(expected int64, params ...any) *ZodFile[T, R]

Size sets exact file size validation

func (*ZodFile[T, R]) StrictParse added in v0.4.0

func (z *ZodFile[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates input with compile-time type safety and enhanced performance. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodFile[T, R]) Transform

func (z *ZodFile[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates a transformation pipeline

type ZodFileDef

type ZodFileDef struct {
	core.ZodTypeDef
}

ZodFileDef represents the definition for a file type

type ZodFileInternals

type ZodFileInternals struct {
	core.ZodTypeInternals
	Def *ZodFileDef // Schema definition
}

ZodFileInternals holds the internal state for file validation

type ZodFloat

type ZodFloat[T FloatConstraint, R any] = ZodFloatTyped[T, R]

ZodFloat is now a generic type alias for ZodFloatTyped This provides a unified interface for all float types

type ZodFloatDef

type ZodFloatDef struct {
	core.ZodTypeDef
}

ZodFloatDef defines the configuration for float validation

type ZodFloatInternals

type ZodFloatInternals struct {
	core.ZodTypeInternals
	Def *ZodFloatDef // Schema definition
}

ZodFloatInternals contains float validator internal state

type ZodFloatTyped added in v0.3.0

type ZodFloatTyped[T FloatConstraint, R any] struct {
	// contains filtered or unexported fields
}

ZodFloatTyped represents a floating-point validation schema with dual generic parameters T = base type (float32, float64, etc.), R = constraint type (T or *T)

func CoercedFloat added in v0.3.0

func CoercedFloat[T FloatConstraint](params ...any) *ZodFloatTyped[T, T]

CoercedFloat creates a flexible float schema with coercion enabled

func CoercedFloat32 added in v0.2.1

func CoercedFloat32(params ...any) *ZodFloatTyped[float32, float32]

CoercedFloat32 creates a float32 schema with coercion enabled

func CoercedFloat32Ptr added in v0.3.0

func CoercedFloat32Ptr(params ...any) *ZodFloatTyped[float32, *float32]

CoercedFloat32Ptr creates a *float32 schema with coercion enabled

func CoercedFloat64 added in v0.2.1

func CoercedFloat64(params ...any) *ZodFloatTyped[float64, float64]

CoercedFloat64 creates a float64 schema with coercion enabled

func CoercedFloat64Ptr added in v0.3.0

func CoercedFloat64Ptr(params ...any) *ZodFloatTyped[float64, *float64]

CoercedFloat64Ptr creates a *float64 schema with coercion enabled

func CoercedFloatPtr added in v0.3.0

func CoercedFloatPtr(params ...any) *ZodFloatTyped[float64, *float64]

CoercedFloatPtr creates a *float64 schema with coercion enabled

func CoercedNumber added in v0.2.1

func CoercedNumber(params ...any) *ZodFloatTyped[float64, float64]

CoercedNumber creates a number schema with coercion enabled (alias for CoercedFloat64)

func CoercedNumberPtr added in v0.3.0

func CoercedNumberPtr(params ...any) *ZodFloatTyped[float64, *float64]

CoercedNumberPtr creates a *number schema with coercion enabled (alias for CoercedFloat64Ptr)

func Float

func Float(params ...any) *ZodFloatTyped[float64, float64]

Float creates a flexible float64 schema (alias for Float64).

func Float32

func Float32(params ...any) *ZodFloatTyped[float32, float32]

Float32 creates a float32 schema

func Float32Ptr added in v0.3.0

func Float32Ptr(params ...any) *ZodFloatTyped[float32, *float32]

Float32Ptr creates a schema for *float32.

func Float64

func Float64(params ...any) *ZodFloatTyped[float64, float64]

Float64 creates a float64 schema

func Float64Ptr added in v0.3.0

func Float64Ptr(params ...any) *ZodFloatTyped[float64, *float64]

Float64Ptr creates a schema for *float64.

func FloatPtr added in v0.3.0

func FloatPtr(params ...any) *ZodFloatTyped[float64, *float64]

FloatPtr creates a schema for *float64 (alias for Float64Ptr).

func FloatTyped added in v0.3.0

func FloatTyped[T FloatConstraint](params ...any) *ZodFloatTyped[T, T]

FloatTyped creates a generic float schema with automatic type inference. It automatically determines the appropriate type code based on the generic type parameter. Usage: FloatTyped[float32](), FloatTyped[float64](), etc.

func Number

func Number(params ...any) *ZodFloatTyped[float64, float64]

Number creates a number schema (alias for Float64).

func NumberPtr added in v0.3.0

func NumberPtr(params ...any) *ZodFloatTyped[float64, *float64]

NumberPtr creates a schema for *float64 (alias for Float64Ptr).

func (*ZodFloatTyped[T, R]) And added in v0.5.4

func (z *ZodFloatTyped[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Float64().Min(0.0).And(gozod.Float64().Max(100.0))
result, _ := schema.Parse(50.5) // Must satisfy both constraints

func (*ZodFloatTyped[T, R]) Check added in v0.3.0

func (z *ZodFloatTyped[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFloatTyped[T, R]

Check adds a custom validation function for ZodFloatTyped that can report multiple issues.

func (*ZodFloatTyped[T, R]) CloneFrom added in v0.3.0

func (z *ZodFloatTyped[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodFloatTyped[T, R]) Coerce added in v0.3.0

func (z *ZodFloatTyped[T, R]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for float type conversion

func (*ZodFloatTyped[T, R]) Default added in v0.3.0

func (z *ZodFloatTyped[T, R]) Default(v float64) *ZodFloatTyped[T, R]

Default keeps the current constraint type R.

func (*ZodFloatTyped[T, R]) DefaultFunc added in v0.3.0

func (z *ZodFloatTyped[T, R]) DefaultFunc(fn func() float64) *ZodFloatTyped[T, R]

DefaultFunc keeps the current constraint type R.

func (*ZodFloatTyped[T, R]) Describe added in v0.5.4

func (z *ZodFloatTyped[T, R]) Describe(description string) *ZodFloatTyped[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodFloatTyped[T, R]) ExactOptional added in v0.5.4

func (z *ZodFloatTyped[T, R]) ExactOptional() *ZodFloatTyped[T, R]

ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional(), which accepts both absent keys AND nil values, ExactOptional() only accepts absent keys in object fields.

func (*ZodFloatTyped[T, R]) Finite added in v0.3.0

func (z *ZodFloatTyped[T, R]) Finite(params ...any) *ZodFloatTyped[T, R]

Finite adds finite number validation (not NaN or Infinity)

func (*ZodFloatTyped[T, R]) GetInternals added in v0.3.0

func (z *ZodFloatTyped[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodFloatTyped[T, R]) Gt added in v0.3.0

func (z *ZodFloatTyped[T, R]) Gt(value float64, params ...any) *ZodFloatTyped[T, R]

Gt adds greater than validation (exclusive)

func (*ZodFloatTyped[T, R]) Gte added in v0.3.0

func (z *ZodFloatTyped[T, R]) Gte(value float64, params ...any) *ZodFloatTyped[T, R]

Gte adds greater than or equal validation (inclusive)

func (*ZodFloatTyped[T, R]) Int added in v0.3.0

func (z *ZodFloatTyped[T, R]) Int(params ...any) *ZodFloatTyped[T, R]

Int adds integer validation (no decimal part)

func (*ZodFloatTyped[T, R]) IsNilable added in v0.3.0

func (z *ZodFloatTyped[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodFloatTyped[T, R]) IsOptional added in v0.3.0

func (z *ZodFloatTyped[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodFloatTyped[T, R]) Lt added in v0.3.0

func (z *ZodFloatTyped[T, R]) Lt(value float64, params ...any) *ZodFloatTyped[T, R]

Lt adds less than validation (exclusive)

func (*ZodFloatTyped[T, R]) Lte added in v0.3.0

func (z *ZodFloatTyped[T, R]) Lte(value float64, params ...any) *ZodFloatTyped[T, R]

Lte adds less than or equal validation (inclusive)

func (*ZodFloatTyped[T, R]) Max added in v0.3.0

func (z *ZodFloatTyped[T, R]) Max(maximum float64, params ...any) *ZodFloatTyped[T, R]

Max adds maximum value validation (alias for Lte)

func (*ZodFloatTyped[T, R]) Meta added in v0.3.1

func (z *ZodFloatTyped[T, R]) Meta(meta core.GlobalMeta) *ZodFloatTyped[T, R]

Meta stores metadata for this float schema in the global registry.

func (*ZodFloatTyped[T, R]) Min added in v0.3.0

func (z *ZodFloatTyped[T, R]) Min(minimum float64, params ...any) *ZodFloatTyped[T, R]

Min adds minimum value validation (alias for Gte)

func (*ZodFloatTyped[T, R]) MultipleOf added in v0.3.0

func (z *ZodFloatTyped[T, R]) MultipleOf(value float64, params ...any) *ZodFloatTyped[T, R]

MultipleOf adds multiple of validation

func (*ZodFloatTyped[T, R]) MustParse added in v0.3.0

func (z *ZodFloatTyped[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse is the type-safe variant that panics on error.

func (*ZodFloatTyped[T, R]) MustStrictParse added in v0.4.0

func (z *ZodFloatTyped[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodFloatTyped[T, R]) Negative added in v0.3.0

func (z *ZodFloatTyped[T, R]) Negative(params ...any) *ZodFloatTyped[T, R]

Negative adds negative number validation (< 0)

func (*ZodFloatTyped[T, R]) Nilable added in v0.3.0

func (z *ZodFloatTyped[T, R]) Nilable() *ZodFloatTyped[T, *T]

Nilable returns a schema that accepts the base type T or nil, with constraint type *T.

func (*ZodFloatTyped[T, R]) NonNegative added in v0.3.0

func (z *ZodFloatTyped[T, R]) NonNegative(params ...any) *ZodFloatTyped[T, R]

NonNegative adds non-negative number validation (>= 0, alias for nonnegative)

func (*ZodFloatTyped[T, R]) NonOptional added in v0.3.0

func (z *ZodFloatTyped[T, R]) NonOptional() *ZodFloatTyped[T, T]

NonOptional removes optional flag and returns value constraint (T). Mirrors Optional() -> NonOptional() pattern, enabling strict non-nil validation.

func (*ZodFloatTyped[T, R]) NonPositive added in v0.3.0

func (z *ZodFloatTyped[T, R]) NonPositive(params ...any) *ZodFloatTyped[T, R]

NonPositive adds non-positive number validation (<= 0, alias for nonpositive)

func (*ZodFloatTyped[T, R]) Nullish added in v0.3.0

func (z *ZodFloatTyped[T, R]) Nullish() *ZodFloatTyped[T, *T]

Nullish combines optional and nilable modifiers for maximum flexibility.

func (*ZodFloatTyped[T, R]) Optional added in v0.3.0

func (z *ZodFloatTyped[T, R]) Optional() *ZodFloatTyped[T, *T]

Optional returns a schema that accepts the base type T or nil, with constraint type *T.

func (*ZodFloatTyped[T, R]) Or added in v0.5.4

func (z *ZodFloatTyped[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Float64().Or(gozod.Int())
result, _ := schema.Parse(3.14)  // Accepts float
result, _ = schema.Parse(42)     // Accepts int

func (*ZodFloatTyped[T, R]) Overwrite added in v0.3.0

func (z *ZodFloatTyped[T, R]) Overwrite(transform func(T) T, params ...any) *ZodFloatTyped[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodFloatTyped[T, R]) Parse added in v0.3.0

func (z *ZodFloatTyped[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse returns a value that matches the constraint type R with full type safety.

func (*ZodFloatTyped[T, R]) ParseAny added in v0.3.0

func (z *ZodFloatTyped[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodFloatTyped[T, R]) Pipe added in v0.3.0

func (z *ZodFloatTyped[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

func (*ZodFloatTyped[T, R]) Positive added in v0.3.0

func (z *ZodFloatTyped[T, R]) Positive(params ...any) *ZodFloatTyped[T, R]

Positive adds positive number validation (> 0)

func (*ZodFloatTyped[T, R]) Prefault added in v0.3.0

func (z *ZodFloatTyped[T, R]) Prefault(v float64) *ZodFloatTyped[T, R]

Prefault keeps the current constraint type R.

func (*ZodFloatTyped[T, R]) PrefaultFunc added in v0.3.0

func (z *ZodFloatTyped[T, R]) PrefaultFunc(fn func() float64) *ZodFloatTyped[T, R]

PrefaultFunc keeps the current constraint type R.

func (*ZodFloatTyped[T, R]) Refine added in v0.3.0

func (z *ZodFloatTyped[T, R]) Refine(fn func(T) bool, params ...any) *ZodFloatTyped[T, R]

Refine applies type-safe validation using the base type T instead of constraint type T. The callback will be executed even when the value is nil (for pointer schemas) to align with Zod v4 semantics.

func (*ZodFloatTyped[T, R]) RefineAny added in v0.3.0

func (z *ZodFloatTyped[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodFloatTyped[T, R]

RefineAny adds flexible custom validation logic

func (*ZodFloatTyped[T, R]) Safe added in v0.3.0

func (z *ZodFloatTyped[T, R]) Safe(params ...any) *ZodFloatTyped[T, R]

Safe adds safe number validation (within JavaScript safe integer range)

func (*ZodFloatTyped[T, R]) Step added in v0.3.0

func (z *ZodFloatTyped[T, R]) Step(step float64, params ...any) *ZodFloatTyped[T, R]

Step adds step validation (alias for MultipleOf to match Zod)

func (*ZodFloatTyped[T, R]) StrictParse added in v0.4.0

func (z *ZodFloatTyped[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodFloatTyped[T, R]) Transform added in v0.3.0

func (z *ZodFloatTyped[T, R]) Transform(fn func(float64, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Float types implement direct extraction of float64 values for transformation.

WrapFn Implementation:

  1. Create a wrapper function that extracts float64 from constraint type R
  2. Apply the user's transformation function to the extracted float64
  3. Return a ZodTransform with the wrapper function

Zero Redundancy:

  • No floatTypeConverter structure needed
  • Direct function composition for maximum performance
  • Type-safe extraction from constraint type R to float64

Example:

schema := Float64().Min(0.0).Transform(func(f float64, ctx *RefinementContext) (string, error) {
    return fmt.Sprintf("%.2f", f), nil
})

func (*ZodFloatTyped[T, R]) With added in v0.5.4

func (z *ZodFloatTyped[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFloatTyped[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

This method exists for TypeScript Zod v4 API compatibility, where .with() is simply an alias for .check().

type ZodFunction

type ZodFunction[T FunctionConstraint] struct {
	// contains filtered or unexported fields
}

ZodFunction represents a function validation schema with type safety

func Function

func Function(params ...any) *ZodFunction[any]

Function creates a function schema

func FunctionPtr added in v0.3.0

func FunctionPtr(params ...any) *ZodFunction[*any]

FunctionPtr creates a schema for *function

func FunctionTyped added in v0.3.0

func FunctionTyped[T FunctionConstraint](params ...any) *ZodFunction[T]

FunctionTyped is the underlying generic function for creating function schemas

func (*ZodFunction[T]) CloneFrom added in v0.3.0

func (z *ZodFunction[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodFunction[T]) Default

func (z *ZodFunction[T]) Default(v any) *ZodFunction[T]

Default preserves the current generic type T

func (*ZodFunction[T]) DefaultFunc

func (z *ZodFunction[T]) DefaultFunc(fn func() any) *ZodFunction[T]

DefaultFunc preserves the current generic type T

func (*ZodFunction[T]) Describe added in v0.5.4

func (z *ZodFunction[T]) Describe(description string) *ZodFunction[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodFunction[T]) GetInternals

func (z *ZodFunction[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodFunction[T]) Implement

func (z *ZodFunction[T]) Implement(fn any) (any, error)

Implement wraps a function with input/output validation

func (*ZodFunction[T]) Input

func (z *ZodFunction[T]) Input(inputSchema core.ZodType[any]) *ZodFunction[T]

Input sets the input schema for function arguments

func (*ZodFunction[T]) IsNilable added in v0.3.0

func (z *ZodFunction[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodFunction[T]) IsOptional added in v0.3.0

func (z *ZodFunction[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodFunction[T]) Meta added in v0.3.1

func (z *ZodFunction[T]) Meta(meta core.GlobalMeta) *ZodFunction[T]

Meta stores metadata for this function schema.

func (*ZodFunction[T]) MustParse

func (z *ZodFunction[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error

func (*ZodFunction[T]) MustStrictParse added in v0.4.0

func (z *ZodFunction[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodFunction[T]) Nilable

func (z *ZodFunction[T]) Nilable() *ZodFunction[*any]

Nilable allows the function to be nil

func (*ZodFunction[T]) Nullish

func (z *ZodFunction[T]) Nullish() *ZodFunction[*any]

Nullish combines optional and nilable modifiers

func (*ZodFunction[T]) Optional

func (z *ZodFunction[T]) Optional() *ZodFunction[*any]

Optional allows the function to be nil

func (*ZodFunction[T]) Output

func (z *ZodFunction[T]) Output(outputSchema core.ZodType[any]) *ZodFunction[T]

Output sets the output schema for function return value

func (*ZodFunction[T]) Overwrite added in v0.3.0

func (z *ZodFunction[T]) Overwrite(transform func(T) T, params ...any) *ZodFunction[T]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodFunction[T]) Parse

func (z *ZodFunction[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse validates and returns a function that performs input/output validation

func (*ZodFunction[T]) ParseAny added in v0.3.0

func (z *ZodFunction[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodFunction[T]) Pipe

func (z *ZodFunction[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodFunction[T]) Prefault

func (z *ZodFunction[T]) Prefault(v any) *ZodFunction[T]

Prefault preserves the current generic type T

func (*ZodFunction[T]) PrefaultFunc

func (z *ZodFunction[T]) PrefaultFunc(fn func() any) *ZodFunction[T]

PrefaultFunc preserves the current generic type T

func (*ZodFunction[T]) Refine

func (z *ZodFunction[T]) Refine(fn func(T) bool, params ...any) *ZodFunction[T]

Refine applies custom validation function

func (*ZodFunction[T]) RefineAny

func (z *ZodFunction[T]) RefineAny(fn func(any) bool, params ...any) *ZodFunction[T]

RefineAny adds flexible custom validation logic

func (*ZodFunction[T]) StrictParse added in v0.4.0

func (z *ZodFunction[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

func (*ZodFunction[T]) Transform

func (z *ZodFunction[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using WrapFn pattern

type ZodFunctionDef

type ZodFunctionDef struct {
	core.ZodTypeDef
	Input  core.ZodType[any] // Schema for validating input arguments
	Output core.ZodType[any] // Schema for validating output result
}

ZodFunctionDef defines the configuration for function validation

type ZodFunctionInternals

type ZodFunctionInternals struct {
	core.ZodTypeInternals
	Def    *ZodFunctionDef   // Schema definition
	Input  core.ZodType[any] // Input validation schema
	Output core.ZodType[any] // Output validation schema
}

ZodFunctionInternals contains function validator internal state

type ZodGUID added in v0.5.5

type ZodGUID[T StringConstraint] struct{ *ZodString[T] }

func Guid added in v0.5.5

func Guid(params ...any) *ZodGUID[string]

Guid creates a GUID schema that validates strings in GUID format (8-4-4-4-12 hex pattern). GUID is similar to UUID but accepts any hex characters regardless of version.

func GuidPtr added in v0.5.5

func GuidPtr(params ...any) *ZodGUID[*string]

GuidPtr creates a pointer GUID schema.

func (*ZodGUID[T]) MustStrictParse added in v0.5.5

func (z *ZodGUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodGUID[T]) StrictParse added in v0.5.5

func (z *ZodGUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodHex added in v0.5.4

type ZodHex[T StringConstraint] struct{ *ZodString[T] }

ZodHex represents a hexadecimal string validation schema

func Hex added in v0.5.4

func Hex(params ...any) *ZodHex[string]

Hex creates a hexadecimal string validation schema TypeScript Zod v4 equivalent: z.hex()

Examples:

schema := Hex()
schema.Parse("")           // valid (empty string is valid hex)
schema.Parse("123abc")     // valid
schema.Parse("DEADBEEF")   // valid
schema.Parse("xyz")        // invalid

func HexPtr added in v0.5.4

func HexPtr(params ...any) *ZodHex[*string]

HexPtr creates a hexadecimal string validation schema for pointer types

func HexTyped added in v0.5.4

func HexTyped[T StringConstraint](params ...any) *ZodHex[T]

HexTyped creates a hexadecimal string validation schema for a specific type

func (*ZodHex[T]) MustStrictParse added in v0.5.4

func (z *ZodHex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodHex[T]) StrictParse added in v0.5.4

func (z *ZodHex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodHostname added in v0.5.4

type ZodHostname[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodHostname represents a DNS hostname validation schema

func Hostname added in v0.5.4

func Hostname(params ...any) *ZodHostname[string]

Hostname creates a new hostname schema

func HostnamePtr added in v0.5.4

func HostnamePtr(params ...any) *ZodHostname[*string]

HostnamePtr creates a new hostname schema with pointer type

func HostnameTyped added in v0.5.4

func HostnameTyped[T NetworkConstraint](params ...any) *ZodHostname[T]

HostnameTyped creates a new hostname schema with specific type

func (*ZodHostname[T]) And added in v0.5.4

func (z *ZodHostname[T]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema

func (*ZodHostname[T]) Coerce added in v0.5.4

func (z *ZodHostname[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface

func (*ZodHostname[T]) Default added in v0.5.4

func (z *ZodHostname[T]) Default(v string) *ZodHostname[T]

Default sets a default value

func (*ZodHostname[T]) Describe added in v0.5.4

func (z *ZodHostname[T]) Describe(description string) *ZodHostname[T]

Describe adds a description to the schema

func (*ZodHostname[T]) GetInternals added in v0.5.4

func (z *ZodHostname[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodHostname[T]) IsNilable added in v0.5.4

func (z *ZodHostname[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodHostname[T]) IsOptional added in v0.5.4

func (z *ZodHostname[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodHostname[T]) MustParse added in v0.5.4

func (z *ZodHostname[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodHostname[T]) MustStrictParse added in v0.5.4

func (z *ZodHostname[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error

func (*ZodHostname[T]) Nilable added in v0.5.4

func (z *ZodHostname[T]) Nilable() *ZodHostname[*string]

Nilable returns a schema that accepts nil values

func (*ZodHostname[T]) Optional added in v0.5.4

func (z *ZodHostname[T]) Optional() *ZodHostname[*string]

Optional returns a schema that accepts nil values

func (*ZodHostname[T]) Or added in v0.5.4

func (z *ZodHostname[T]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema

func (*ZodHostname[T]) Parse added in v0.5.4

func (z *ZodHostname[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse validates and returns a hostname string

func (*ZodHostname[T]) ParseAny added in v0.5.4

func (z *ZodHostname[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result

func (*ZodHostname[T]) StrictParse added in v0.5.4

func (z *ZodHostname[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety

type ZodHostnameDef added in v0.5.4

type ZodHostnameDef struct {
	core.ZodTypeDef
}

ZodHostnameDef defines the configuration for hostname validation

type ZodHostnameInternals added in v0.5.4

type ZodHostnameInternals struct {
	core.ZodTypeInternals
	Def *ZodHostnameDef
}

ZodHostnameInternals contains hostname validator internal state

type ZodIPv4

type ZodIPv4[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodIPv4 represents an IPv4 address validation schema

func CoercedIPv4 added in v0.3.0

func CoercedIPv4(params ...any) *ZodIPv4[string]

CoercedIPv4 creates coerced IPv4 schema that attempts string conversion

func IPv4

func IPv4(params ...any) *ZodIPv4[string]

IPv4 creates IPv4 address schema with type-inference support

func IPv4Ptr added in v0.3.0

func IPv4Ptr(params ...any) *ZodIPv4[*string]

IPv4Ptr creates schema for *string IPv4

func IPv4Typed added in v0.3.0

func IPv4Typed[T NetworkConstraint](params ...any) *ZodIPv4[T]

IPv4Typed is the generic constructor for IPv4 address schemas

func (*ZodIPv4[T]) CloneFrom added in v0.3.0

func (z *ZodIPv4[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodIPv4[T]) Coerce added in v0.3.0

func (z *ZodIPv4[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface using coerce package

func (*ZodIPv4[T]) Default

func (z *ZodIPv4[T]) Default(v string) *ZodIPv4[T]

Default preserves current generic type T

func (*ZodIPv4[T]) DefaultFunc

func (z *ZodIPv4[T]) DefaultFunc(fn func() string) *ZodIPv4[T]

DefaultFunc preserves current generic type T

func (*ZodIPv4[T]) GetInternals

func (z *ZodIPv4[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodIPv4[T]) IsNilable added in v0.3.0

func (z *ZodIPv4[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodIPv4[T]) IsOptional added in v0.3.0

func (z *ZodIPv4[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodIPv4[T]) MustParse

func (z *ZodIPv4[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodIPv4[T]) MustStrictParse added in v0.4.0

func (z *ZodIPv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodIPv4[T]) Nilable

func (z *ZodIPv4[T]) Nilable() *ZodIPv4[*string]

Nilable allows nil values, returns pointer type

func (*ZodIPv4[T]) Nullish added in v0.3.0

func (z *ZodIPv4[T]) Nullish() *ZodIPv4[*string]

Nullish combines optional and nilable modifiers

func (*ZodIPv4[T]) Optional

func (z *ZodIPv4[T]) Optional() *ZodIPv4[*string]

Optional allows nil values, returns pointer type for nullable semantics

func (*ZodIPv4[T]) Parse

func (z *ZodIPv4[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns type-safe IPv4 address using unified engine API

func (*ZodIPv4[T]) ParseAny added in v0.3.0

func (z *ZodIPv4[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodIPv4[T]) Pipe

func (z *ZodIPv4[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodIPv4[T]) Prefault

func (z *ZodIPv4[T]) Prefault(v string) *ZodIPv4[T]

Prefault provides fallback values on validation failure

func (*ZodIPv4[T]) PrefaultFunc

func (z *ZodIPv4[T]) PrefaultFunc(fn func() string) *ZodIPv4[T]

PrefaultFunc provides dynamic fallback values

func (*ZodIPv4[T]) Refine added in v0.3.0

func (z *ZodIPv4[T]) Refine(fn func(T) bool, params ...any) *ZodIPv4[T]

Refine adds type-safe custom validation logic

func (*ZodIPv4[T]) RefineAny

func (z *ZodIPv4[T]) RefineAny(fn func(any) bool, params ...any) *ZodIPv4[T]

RefineAny adds flexible custom validation logic

func (*ZodIPv4[T]) StrictParse added in v0.4.0

func (z *ZodIPv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodIPv4[T]) Transform added in v0.3.0

func (z *ZodIPv4[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates type-safe transformation using WrapFn pattern

type ZodIPv4Def

type ZodIPv4Def struct {
	core.ZodTypeDef
}

ZodIPv4Def defines the configuration for IPv4 address validation

type ZodIPv4Internals

type ZodIPv4Internals struct {
	core.ZodTypeInternals
	Def *ZodIPv4Def // Schema definition
}

ZodIPv4Internals contains IPv4 validator internal state

type ZodIPv6

type ZodIPv6[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodIPv6 represents an IPv6 address validation schema

func CoercedIPv6 added in v0.3.0

func CoercedIPv6(params ...any) *ZodIPv6[string]

CoercedIPv6 creates coerced IPv6 schema that attempts string conversion

func IPv6

func IPv6(params ...any) *ZodIPv6[string]

IPv6 creates IPv6 address schema with type-inference support

func IPv6Ptr added in v0.3.0

func IPv6Ptr(params ...any) *ZodIPv6[*string]

IPv6Ptr creates schema for *string IPv6

func IPv6Typed added in v0.3.0

func IPv6Typed[T NetworkConstraint](params ...any) *ZodIPv6[T]

IPv6Typed is the generic constructor for IPv6 address schemas

func (*ZodIPv6[T]) CloneFrom added in v0.3.0

func (z *ZodIPv6[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodIPv6[T]) Coerce added in v0.3.0

func (z *ZodIPv6[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface using coerce package

func (*ZodIPv6[T]) Default

func (z *ZodIPv6[T]) Default(v string) *ZodIPv6[T]

Default preserves current generic type T

func (*ZodIPv6[T]) DefaultFunc

func (z *ZodIPv6[T]) DefaultFunc(fn func() string) *ZodIPv6[T]

DefaultFunc preserves current generic type T

func (*ZodIPv6[T]) GetInternals

func (z *ZodIPv6[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodIPv6[T]) IsNilable added in v0.3.0

func (z *ZodIPv6[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodIPv6[T]) IsOptional added in v0.3.0

func (z *ZodIPv6[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodIPv6[T]) MustParse

func (z *ZodIPv6[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodIPv6[T]) MustStrictParse added in v0.4.0

func (z *ZodIPv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodIPv6[T]) Nilable

func (z *ZodIPv6[T]) Nilable() *ZodIPv6[*string]

Nilable allows nil values, returns pointer type

func (*ZodIPv6[T]) Nullish added in v0.3.0

func (z *ZodIPv6[T]) Nullish() *ZodIPv6[*string]

Nullish combines optional and nilable modifiers

func (*ZodIPv6[T]) Optional

func (z *ZodIPv6[T]) Optional() *ZodIPv6[*string]

Optional allows nil values, returns pointer type for nullable semantics

func (*ZodIPv6[T]) Parse

func (z *ZodIPv6[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns type-safe IPv6 address using unified engine API

func (*ZodIPv6[T]) ParseAny added in v0.3.0

func (z *ZodIPv6[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodIPv6[T]) Pipe

func (z *ZodIPv6[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodIPv6[T]) Prefault

func (z *ZodIPv6[T]) Prefault(v string) *ZodIPv6[T]

Prefault provides fallback values on validation failure

func (*ZodIPv6[T]) PrefaultFunc

func (z *ZodIPv6[T]) PrefaultFunc(fn func() string) *ZodIPv6[T]

PrefaultFunc provides dynamic fallback values

func (*ZodIPv6[T]) Refine added in v0.3.0

func (z *ZodIPv6[T]) Refine(fn func(T) bool, params ...any) *ZodIPv6[T]

Refine adds type-safe custom validation logic

func (*ZodIPv6[T]) RefineAny

func (z *ZodIPv6[T]) RefineAny(fn func(any) bool, params ...any) *ZodIPv6[T]

RefineAny adds flexible custom validation logic

func (*ZodIPv6[T]) StrictParse added in v0.4.0

func (z *ZodIPv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodIPv6[T]) Transform

func (z *ZodIPv6[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates type-safe transformation using WrapFn pattern

type ZodIPv6Def

type ZodIPv6Def struct {
	core.ZodTypeDef
}

ZodIPv6Def defines the configuration for IPv6 address validation

type ZodIPv6Internals

type ZodIPv6Internals struct {
	core.ZodTypeInternals
	Def *ZodIPv6Def // Schema definition
}

ZodIPv6Internals contains IPv6 validator internal state

type ZodInteger

type ZodInteger[T IntegerConstraint, R any] = ZodIntegerTyped[T, R]

ZodInteger represents a flexible integer validation schema that accepts any integer type This is a type alias for ZodIntegerTyped[int64, int64] to provide a unified interface

func Integer

func Integer(params ...any) *ZodInteger[int64, int64]

Integer creates a flexible integer schema that accepts any integer type Now returns ZodInteger[int64, int64] which is equivalent to ZodIntegerTyped[int64, int64]

type ZodIntegerDef

type ZodIntegerDef struct {
	core.ZodTypeDef
}

ZodIntegerDef defines the configuration for integer validation

type ZodIntegerInternals

type ZodIntegerInternals struct {
	core.ZodTypeInternals
	Def *ZodIntegerDef // Schema definition
}

ZodIntegerInternals contains integer validator internal state

type ZodIntegerTyped added in v0.3.0

type ZodIntegerTyped[T IntegerConstraint, R any] struct {
	// contains filtered or unexported fields
}

ZodIntegerTyped represents an integer validation schema with dual generic parameters T = base type (int, int32, int64, etc.), R = constraint type (T or *T)

func Byte

func Byte(params ...any) *ZodIntegerTyped[uint8, uint8]

Byte creates a uint8 schema (alias for byte).

func BytePtr added in v0.3.0

func BytePtr(params ...any) *ZodIntegerTyped[uint8, *uint8]

BytePtr creates a schema for *uint8 (alias for *byte).

func CoercedInt added in v0.2.1

func CoercedInt(params ...any) *ZodIntegerTyped[int, int]

CoercedInt creates an int schema with coercion enabled

func CoercedInt8 added in v0.2.1

func CoercedInt8(params ...any) *ZodIntegerTyped[int8, int8]

CoercedInt8 creates an int8 schema with coercion enabled

func CoercedInt8Ptr added in v0.3.0

func CoercedInt8Ptr(params ...any) *ZodIntegerTyped[int8, *int8]

CoercedInt8Ptr creates a *int8 schema with coercion enabled

func CoercedInt16 added in v0.2.1

func CoercedInt16(params ...any) *ZodIntegerTyped[int16, int16]

CoercedInt16 creates an int16 schema with coercion enabled

func CoercedInt16Ptr added in v0.3.0

func CoercedInt16Ptr(params ...any) *ZodIntegerTyped[int16, *int16]

CoercedInt16Ptr creates a *int16 schema with coercion enabled

func CoercedInt32 added in v0.2.1

func CoercedInt32(params ...any) *ZodIntegerTyped[int32, int32]

CoercedInt32 creates an int32 schema with coercion enabled

func CoercedInt32Ptr added in v0.3.0

func CoercedInt32Ptr(params ...any) *ZodIntegerTyped[int32, *int32]

CoercedInt32Ptr creates a *int32 schema with coercion enabled

func CoercedInt64 added in v0.2.1

func CoercedInt64(params ...any) *ZodIntegerTyped[int64, int64]

CoercedInt64 creates an int64 schema with coercion enabled

func CoercedInt64Ptr added in v0.3.0

func CoercedInt64Ptr(params ...any) *ZodIntegerTyped[int64, *int64]

CoercedInt64Ptr creates a *int64 schema with coercion enabled

func CoercedIntPtr added in v0.3.0

func CoercedIntPtr(params ...any) *ZodIntegerTyped[int, *int]

CoercedIntPtr creates a *int schema with coercion enabled

func CoercedInteger added in v0.3.0

func CoercedInteger(params ...any) *ZodIntegerTyped[int64, int64]

CoercedInteger creates a int64 schema with coercion enabled

func CoercedIntegerPtr added in v0.3.0

func CoercedIntegerPtr(params ...any) *ZodIntegerTyped[int64, *int64]

CoercedIntegerPtr creates a *int64 schema with coercion enabled

func CoercedUint added in v0.2.1

func CoercedUint(params ...any) *ZodIntegerTyped[uint, uint]

CoercedUint creates a uint schema with coercion enabled

func CoercedUint8 added in v0.2.1

func CoercedUint8(params ...any) *ZodIntegerTyped[uint8, uint8]

CoercedUint8 creates a uint8 schema with coercion enabled

func CoercedUint8Ptr added in v0.3.0

func CoercedUint8Ptr(params ...any) *ZodIntegerTyped[uint8, *uint8]

CoercedUint8Ptr creates a *uint8 schema with coercion enabled

func CoercedUint16 added in v0.2.1

func CoercedUint16(params ...any) *ZodIntegerTyped[uint16, uint16]

CoercedUint16 creates a uint16 schema with coercion enabled

func CoercedUint16Ptr added in v0.3.0

func CoercedUint16Ptr(params ...any) *ZodIntegerTyped[uint16, *uint16]

CoercedUint16Ptr creates a *uint16 schema with coercion enabled

func CoercedUint32 added in v0.2.1

func CoercedUint32(params ...any) *ZodIntegerTyped[uint32, uint32]

CoercedUint32 creates a uint32 schema with coercion enabled

func CoercedUint32Ptr added in v0.3.0

func CoercedUint32Ptr(params ...any) *ZodIntegerTyped[uint32, *uint32]

CoercedUint32Ptr creates a *uint32 schema with coercion enabled

func CoercedUint64 added in v0.2.1

func CoercedUint64(params ...any) *ZodIntegerTyped[uint64, uint64]

CoercedUint64 creates a uint64 schema with coercion enabled

func CoercedUint64Ptr added in v0.3.0

func CoercedUint64Ptr(params ...any) *ZodIntegerTyped[uint64, *uint64]

CoercedUint64Ptr creates a *uint64 schema with coercion enabled

func CoercedUintPtr added in v0.3.0

func CoercedUintPtr(params ...any) *ZodIntegerTyped[uint, *uint]

CoercedUintPtr creates a *uint schema with coercion enabled

func Int

func Int(params ...any) *ZodIntegerTyped[int, int]

Int creates a standard int schema

func Int8

func Int8(params ...any) *ZodIntegerTyped[int8, int8]

Int8 creates an int8 schema.

func Int8Ptr added in v0.3.0

func Int8Ptr(params ...any) *ZodIntegerTyped[int8, *int8]

Int8Ptr creates a schema for *int8.

func Int16

func Int16(params ...any) *ZodIntegerTyped[int16, int16]

Int16 creates an int16 schema.

func Int16Ptr added in v0.3.0

func Int16Ptr(params ...any) *ZodIntegerTyped[int16, *int16]

Int16Ptr creates a schema for *int16.

func Int32

func Int32(params ...any) *ZodIntegerTyped[int32, int32]

Int32 creates an int32 schema.

func Int32Ptr added in v0.3.0

func Int32Ptr(params ...any) *ZodIntegerTyped[int32, *int32]

Int32Ptr creates a schema for *int32.

func Int64

func Int64(params ...any) *ZodIntegerTyped[int64, int64]

Int64 creates an int64 schema.

func Int64Ptr added in v0.3.0

func Int64Ptr(params ...any) *ZodIntegerTyped[int64, *int64]

Int64Ptr creates a schema for *int64.

func IntPtr added in v0.3.0

func IntPtr(params ...any) *ZodIntegerTyped[int, *int]

IntPtr creates a schema for *int.

func IntegerTyped added in v0.3.0

func IntegerTyped[T IntegerConstraint](params ...any) *ZodIntegerTyped[T, T]

IntegerTyped creates a generic integer schema with automatic type inference. It automatically determines the appropriate type code based on the generic type parameter. Usage: IntegerTyped[int](), IntegerTyped[uint32](), IntegerTyped[int64](), etc.

func Rune

func Rune(params ...any) *ZodIntegerTyped[int32, int32]

Rune creates an int32 schema (alias for rune).

func RunePtr added in v0.3.0

func RunePtr(params ...any) *ZodIntegerTyped[int32, *int32]

RunePtr creates a schema for *int32 (alias for *rune).

func Uint

func Uint(params ...any) *ZodIntegerTyped[uint, uint]

Uint creates a uint schema.

func Uint8

func Uint8(params ...any) *ZodIntegerTyped[uint8, uint8]

Uint8 creates a uint8 schema.

func Uint8Ptr added in v0.3.0

func Uint8Ptr(params ...any) *ZodIntegerTyped[uint8, *uint8]

Uint8Ptr creates a schema for *uint8.

func Uint16

func Uint16(params ...any) *ZodIntegerTyped[uint16, uint16]

Uint16 creates a uint16 schema.

func Uint16Ptr added in v0.3.0

func Uint16Ptr(params ...any) *ZodIntegerTyped[uint16, *uint16]

Uint16Ptr creates a schema for *uint16.

func Uint32

func Uint32(params ...any) *ZodIntegerTyped[uint32, uint32]

Uint32 creates a uint32 schema.

func Uint32Ptr added in v0.3.0

func Uint32Ptr(params ...any) *ZodIntegerTyped[uint32, *uint32]

Uint32Ptr creates a schema for *uint32.

func Uint64

func Uint64(params ...any) *ZodIntegerTyped[uint64, uint64]

Uint64 creates a uint64 schema.

func Uint64Ptr added in v0.3.0

func Uint64Ptr(params ...any) *ZodIntegerTyped[uint64, *uint64]

Uint64Ptr creates a schema for *uint64.

func UintPtr added in v0.3.0

func UintPtr(params ...any) *ZodIntegerTyped[uint, *uint]

UintPtr creates a schema for *uint.

func (*ZodIntegerTyped[T, R]) And added in v0.5.4

func (z *ZodIntegerTyped[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Int().Min(0).And(gozod.Int().Max(100))
result, _ := schema.Parse(50) // Must satisfy both constraints

func (*ZodIntegerTyped[T, R]) Check added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodIntegerTyped[T, R]

Check adds a custom validation function for integer schemas that can push multiple issues.

func (*ZodIntegerTyped[T, R]) CloneFrom added in v0.3.0

func (z *ZodIntegerTyped[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodIntegerTyped[T, R]) Coerce added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for integer type conversion

func (*ZodIntegerTyped[T, R]) Default added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Default(v int64) *ZodIntegerTyped[T, R]

Default keeps the current generic type T.

func (*ZodIntegerTyped[T, R]) DefaultFunc added in v0.3.0

func (z *ZodIntegerTyped[T, R]) DefaultFunc(fn func() int64) *ZodIntegerTyped[T, R]

DefaultFunc keeps the current generic type T.

func (*ZodIntegerTyped[T, R]) Describe added in v0.5.4

func (z *ZodIntegerTyped[T, R]) Describe(description string) *ZodIntegerTyped[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodIntegerTyped[T, R]) ExactOptional added in v0.5.4

func (z *ZodIntegerTyped[T, R]) ExactOptional() *ZodIntegerTyped[T, R]

ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional(), which accepts both absent keys AND nil values, ExactOptional() only accepts absent keys in object fields.

func (*ZodIntegerTyped[T, R]) GetInternals added in v0.3.0

func (z *ZodIntegerTyped[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodIntegerTyped[T, R]) Gt added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Gt(value int64, params ...any) *ZodIntegerTyped[T, R]

Gt adds greater than validation (exclusive)

func (*ZodIntegerTyped[T, R]) Gte added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Gte(value int64, params ...any) *ZodIntegerTyped[T, R]

Gte adds greater than or equal validation (inclusive)

func (*ZodIntegerTyped[T, R]) IsNilable added in v0.3.0

func (z *ZodIntegerTyped[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodIntegerTyped[T, R]) IsOptional added in v0.3.0

func (z *ZodIntegerTyped[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodIntegerTyped[T, R]) Lt added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Lt(value int64, params ...any) *ZodIntegerTyped[T, R]

Lt adds less than validation (exclusive)

func (*ZodIntegerTyped[T, R]) Lte added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Lte(value int64, params ...any) *ZodIntegerTyped[T, R]

Lte adds less than or equal validation (inclusive)

func (*ZodIntegerTyped[T, R]) Max added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Max(maximum int64, params ...any) *ZodIntegerTyped[T, R]

Max adds maximum value validation (alias for Lte)

func (*ZodIntegerTyped[T, R]) Meta added in v0.3.1

func (z *ZodIntegerTyped[T, R]) Meta(meta core.GlobalMeta) *ZodIntegerTyped[T, R]

Meta stores metadata for this integer schema in the global registry.

func (*ZodIntegerTyped[T, R]) Min added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Min(minimum int64, params ...any) *ZodIntegerTyped[T, R]

Min adds minimum value validation (alias for Gte)

func (*ZodIntegerTyped[T, R]) MultipleOf added in v0.3.0

func (z *ZodIntegerTyped[T, R]) MultipleOf(value int64, params ...any) *ZodIntegerTyped[T, R]

MultipleOf adds multiple of validation

func (*ZodIntegerTyped[T, R]) MustParse added in v0.3.0

func (z *ZodIntegerTyped[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse is the type-safe variant that panics on error.

func (*ZodIntegerTyped[T, R]) MustStrictParse added in v0.4.0

func (z *ZodIntegerTyped[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

Example usage:

schema := gozod.Int().Min(0).Max(100)
result := schema.MustStrictParse(42)           // ✅ int → int
result := schema.MustStrictParse(&num)         // ❌ compile error

func (*ZodIntegerTyped[T, R]) Negative added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Negative(params ...any) *ZodIntegerTyped[T, R]

Negative adds negative number validation (< 0)

func (*ZodIntegerTyped[T, R]) Nilable added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Nilable() *ZodIntegerTyped[T, *T]

Nilable returns a schema that accepts the base type T or nil, with constraint type *T.

func (*ZodIntegerTyped[T, R]) NonNegative added in v0.3.0

func (z *ZodIntegerTyped[T, R]) NonNegative(params ...any) *ZodIntegerTyped[T, R]

NonNegative adds non-negative number validation (>= 0, alias for nonnegative)

func (*ZodIntegerTyped[T, R]) NonOptional added in v0.3.0

func (z *ZodIntegerTyped[T, R]) NonOptional() *ZodIntegerTyped[T, T]

NonOptional removes optional flag and returns value constraint (T). It is the counterpart of Optional() when you need to revert a previously optional schema back to a required field while keeping strong type safety.

func (*ZodIntegerTyped[T, R]) NonPositive added in v0.3.0

func (z *ZodIntegerTyped[T, R]) NonPositive(params ...any) *ZodIntegerTyped[T, R]

NonPositive adds non-positive number validation (<= 0, alias for nonpositive)

func (*ZodIntegerTyped[T, R]) Nullish added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Nullish() *ZodIntegerTyped[T, *T]

Nullish combines optional and nilable modifiers for maximum flexibility.

func (*ZodIntegerTyped[T, R]) Optional added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Optional() *ZodIntegerTyped[T, *T]

Optional returns a schema that accepts the base type T or nil, with constraint type *T.

func (*ZodIntegerTyped[T, R]) Or added in v0.5.4

func (z *ZodIntegerTyped[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Int().Or(gozod.String())
result, _ := schema.Parse(42)      // Accepts int
result, _ = schema.Parse("hello")  // Accepts string

func (*ZodIntegerTyped[T, R]) Overwrite added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Overwrite(transform func(T) T, params ...any) *ZodIntegerTyped[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodIntegerTyped[T, R]) Parse added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse returns a value that matches the constraint type R with full type safety.

func (*ZodIntegerTyped[T, R]) ParseAny added in v0.3.0

func (z *ZodIntegerTyped[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodIntegerTyped[T, R]) Pipe added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

func (*ZodIntegerTyped[T, R]) Positive added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Positive(params ...any) *ZodIntegerTyped[T, R]

Positive adds positive number validation (> 0)

func (*ZodIntegerTyped[T, R]) Prefault added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Prefault(v int64) *ZodIntegerTyped[T, R]

Prefault keeps the current generic type T.

func (*ZodIntegerTyped[T, R]) PrefaultFunc added in v0.3.0

func (z *ZodIntegerTyped[T, R]) PrefaultFunc(fn func() R) *ZodIntegerTyped[T, R]

PrefaultFunc keeps the current generic type R.

func (*ZodIntegerTyped[T, R]) Refine added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Refine(fn func(T) bool, params ...any) *ZodIntegerTyped[T, R]

Refine applies type-safe validation using the base type T instead of constraint type T. The callback will be executed even when the value is nil (for pointer schemas) to align with Zod v4 semantics.

func (*ZodIntegerTyped[T, R]) RefineAny added in v0.3.0

func (z *ZodIntegerTyped[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodIntegerTyped[T, R]

RefineAny adds flexible custom validation logic

func (*ZodIntegerTyped[T, R]) Safe added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Safe(params ...any) *ZodIntegerTyped[T, R]

Safe adds safe integer validation (within JavaScript safe integer range)

func (*ZodIntegerTyped[T, R]) Step added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Step(step int64, params ...any) *ZodIntegerTyped[T, R]

Step adds step validation (alias for MultipleOf to match Zod)

func (*ZodIntegerTyped[T, R]) StrictParse added in v0.4.0

func (z *ZodIntegerTyped[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

Example usage:

schema := gozod.Int()
result, err := schema.StrictParse(42)          // ✅ int → int
result, err := schema.StrictParse(&num)        // ❌ compile error
result, err := schema.StrictParse("42")        // ❌ compile error

func (*ZodIntegerTyped[T, R]) Transform added in v0.3.0

func (z *ZodIntegerTyped[T, R]) Transform(fn func(int64, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Integer types implement direct extraction of int64 values for transformation.

func (*ZodIntegerTyped[T, R]) With added in v0.5.4

func (z *ZodIntegerTyped[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodIntegerTyped[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

This method exists for TypeScript Zod v4 API compatibility, where .with() is simply an alias for .check().

type ZodIntersection

type ZodIntersection[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodIntersection represents an intersection validation schema with dual generic parameters T = base type (any), R = constraint type (any or *any)

func Intersection

func Intersection(left, right any, args ...any) *ZodIntersection[any, any]

Intersection creates intersection schema that validates with both schemas - returns value constraint

func IntersectionPtr added in v0.3.0

func IntersectionPtr(left, right any, args ...any) *ZodIntersection[any, *any]

IntersectionPtr creates intersection schema that validates with both schemas - returns pointer constraint

func IntersectionTyped added in v0.3.0

func IntersectionTyped[T any, R any](left, right any, args ...any) *ZodIntersection[T, R]

IntersectionTyped creates typed intersection schema with generic constraints

func (*ZodIntersection[T, R]) And added in v0.5.4

func (z *ZodIntersection[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema, enabling chaining. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.String().Min(3).And(gozod.String().Max(10)).And(gozod.String().RegexString(`^[a-z]+$`))
result, _ := schema.Parse("hello") // Must satisfy all constraints

func (*ZodIntersection[T, R]) CloneFrom

func (z *ZodIntersection[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodIntersection[T, R]) Default

func (z *ZodIntersection[T, R]) Default(v T) *ZodIntersection[T, R]

Default preserves current constraint type R

func (*ZodIntersection[T, R]) DefaultFunc

func (z *ZodIntersection[T, R]) DefaultFunc(fn func() T) *ZodIntersection[T, R]

DefaultFunc preserves current constraint type R

func (*ZodIntersection[T, R]) Describe added in v0.5.4

func (z *ZodIntersection[T, R]) Describe(description string) *ZodIntersection[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodIntersection[T, R]) GetInternals

func (z *ZodIntersection[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodIntersection[T, R]) IsNilable added in v0.3.0

func (z *ZodIntersection[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodIntersection[T, R]) IsOptional added in v0.3.0

func (z *ZodIntersection[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodIntersection[T, R]) Left

func (z *ZodIntersection[T, R]) Left() core.ZodSchema

Left returns the left schema of the intersection

func (*ZodIntersection[T, R]) Meta added in v0.3.1

func (z *ZodIntersection[T, R]) Meta(meta core.GlobalMeta) *ZodIntersection[T, R]

Meta stores metadata for this intersection schema.

func (*ZodIntersection[T, R]) MustParse

func (z *ZodIntersection[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodIntersection[T, R]) MustStrictParse added in v0.4.0

func (z *ZodIntersection[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodIntersection[T, R]) Nilable

func (z *ZodIntersection[T, R]) Nilable() *ZodIntersection[T, *T]

Nilable makes the intersection nilable and returns pointer constraint

func (*ZodIntersection[T, R]) NonOptional added in v0.3.0

func (z *ZodIntersection[T, R]) NonOptional() *ZodIntersection[T, T]

NonOptional removes Optional flag and enforces non-nil value (T).

func (*ZodIntersection[T, R]) Nullish

func (z *ZodIntersection[T, R]) Nullish() *ZodIntersection[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodIntersection[T, R]) Optional

func (z *ZodIntersection[T, R]) Optional() *ZodIntersection[T, *T]

Optional makes the intersection optional and returns pointer constraint

func (*ZodIntersection[T, R]) Or added in v0.5.4

func (z *ZodIntersection[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.String().And(gozod.String().Min(3)).Or(gozod.Int())

func (*ZodIntersection[T, R]) Parse

func (z *ZodIntersection[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using engine.ParseComplex for unified Default/Prefault handling

func (*ZodIntersection[T, R]) ParseAny added in v0.3.0

func (z *ZodIntersection[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodIntersection[T, R]) Pipe

func (z *ZodIntersection[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates validation pipeline to another schema using WrapFn pattern

func (*ZodIntersection[T, R]) Prefault

func (z *ZodIntersection[T, R]) Prefault(v T) *ZodIntersection[T, R]

Prefault provides fallback values on validation failure

func (*ZodIntersection[T, R]) PrefaultFunc

func (z *ZodIntersection[T, R]) PrefaultFunc(fn func() T) *ZodIntersection[T, R]

PrefaultFunc keeps current generic type R.

func (*ZodIntersection[T, R]) Refine

func (z *ZodIntersection[T, R]) Refine(fn func(R) bool, params ...any) *ZodIntersection[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodIntersection[T, R]) RefineAny

func (z *ZodIntersection[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodIntersection[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodIntersection[T, R]) Right

func (z *ZodIntersection[T, R]) Right() core.ZodSchema

Right returns the right schema of the intersection

func (*ZodIntersection[T, R]) StrictParse added in v0.4.0

func (z *ZodIntersection[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates the input using strict parsing rules

func (*ZodIntersection[T, R]) Transform

func (z *ZodIntersection[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates type-safe transformation pipeline using WrapFn pattern

type ZodIntersectionDef

type ZodIntersectionDef struct {
	core.ZodTypeDef
	Left  core.ZodSchema // Left schema using unified interface
	Right core.ZodSchema // Right schema using unified interface
}

ZodIntersectionDef defines the schema definition for intersection validation

type ZodIntersectionInternals

type ZodIntersectionInternals struct {
	core.ZodTypeInternals
	Def   *ZodIntersectionDef // Schema definition reference
	Left  core.ZodSchema      // Left schema for runtime validation
	Right core.ZodSchema      // Right schema for runtime validation
}

ZodIntersectionInternals contains intersection validator internal state

type ZodIso added in v0.3.0

type ZodIso[T IsoConstraint] struct{ *ZodString[T] }

func Iso added in v0.3.0

func Iso(params ...any) *ZodIso[string]

func IsoDate added in v0.3.0

func IsoDate(params ...any) *ZodIso[string]

func IsoDatePtr added in v0.3.0

func IsoDatePtr(params ...any) *ZodIso[*string]

func IsoDateTime added in v0.3.0

func IsoDateTime(params ...any) *ZodIso[string]

func IsoDateTimePtr added in v0.3.0

func IsoDateTimePtr(params ...any) *ZodIso[*string]

func IsoDateTimeTyped added in v0.3.0

func IsoDateTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]

func IsoDateTyped added in v0.3.0

func IsoDateTyped[T IsoConstraint](params ...any) *ZodIso[T]

func IsoDuration added in v0.3.0

func IsoDuration(params ...any) *ZodIso[string]

func IsoDurationPtr added in v0.3.0

func IsoDurationPtr(params ...any) *ZodIso[*string]

func IsoDurationTyped added in v0.3.0

func IsoDurationTyped[T IsoConstraint](params ...any) *ZodIso[T]

func IsoPtr added in v0.3.0

func IsoPtr(params ...any) *ZodIso[*string]

func IsoTime added in v0.3.0

func IsoTime(params ...any) *ZodIso[string]

func IsoTimePtr added in v0.3.0

func IsoTimePtr(params ...any) *ZodIso[*string]

func IsoTimeTyped added in v0.3.0

func IsoTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]

func IsoTyped added in v0.3.0

func IsoTyped[T IsoConstraint](params ...any) *ZodIso[T]

func (*ZodIso[T]) Date added in v0.3.0

func (z *ZodIso[T]) Date(params ...any) *ZodIso[T]

func (*ZodIso[T]) DateTime added in v0.3.0

func (z *ZodIso[T]) DateTime(opts ...IsoDatetimeOptions) *ZodIso[T]

func (*ZodIso[T]) Default added in v0.3.0

func (z *ZodIso[T]) Default(v string) *ZodIso[T]

func (*ZodIso[T]) DefaultFunc added in v0.3.0

func (z *ZodIso[T]) DefaultFunc(fn func() string) *ZodIso[T]

func (*ZodIso[T]) Duration added in v0.3.0

func (z *ZodIso[T]) Duration(params ...any) *ZodIso[T]

func (*ZodIso[T]) GetInternals added in v0.3.0

func (z *ZodIso[T]) GetInternals() *core.ZodTypeInternals

----------------------------------------------------------------------------- Proxy GetInternals -----------------------------------------------------------------------------

func (*ZodIso[T]) Max added in v0.3.0

func (z *ZodIso[T]) Max(maxVal string, params ...any) *ZodIso[T]

func (*ZodIso[T]) Min added in v0.3.0

func (z *ZodIso[T]) Min(minVal string, params ...any) *ZodIso[T]

Range validation using lexicographic comparison (perfect for ISO 8601 strings).

func (*ZodIso[T]) MustStrictParse added in v0.4.0

func (z *ZodIso[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodIso[T]) Nilable added in v0.3.0

func (z *ZodIso[T]) Nilable() *ZodIso[*string]

func (*ZodIso[T]) Nullish added in v0.3.0

func (z *ZodIso[T]) Nullish() *ZodIso[*string]

func (*ZodIso[T]) Optional added in v0.3.0

func (z *ZodIso[T]) Optional() *ZodIso[*string]

func (*ZodIso[T]) Prefault added in v0.3.0

func (z *ZodIso[T]) Prefault(v string) *ZodIso[T]

func (*ZodIso[T]) PrefaultFunc added in v0.3.0

func (z *ZodIso[T]) PrefaultFunc(fn func() string) *ZodIso[T]

func (*ZodIso[T]) StrictParse added in v0.4.0

func (z *ZodIso[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

func (*ZodIso[T]) Time added in v0.3.0

func (z *ZodIso[T]) Time(opts ...IsoTimeOptions) *ZodIso[T]

type ZodJWT added in v0.3.0

type ZodJWT[T StringConstraint] struct{ *ZodString[T] }

func JWT added in v0.3.0

func JWT(params ...any) *ZodJWT[string]

JWT creates a JWT token validation schema Supports various parameter combinations:

JWT() - basic JWT structure validation
JWT("error message") - basic validation with custom error message
JWT(JWTOptions{Algorithm: "HS256"}) - with algorithm constraint
JWT(options, "error message") - options with error message
JWT(options, core.SchemaParams{Description: "JWT"}) - options with schema params

func JWTPtr added in v0.3.0

func JWTPtr(params ...any) *ZodJWT[*string]

JWTPtr creates a JWT token validation schema for pointer type

func JWTTyped added in v0.3.0

func JWTTyped[T StringConstraint](params ...any) *ZodJWT[T]

JWTTyped creates a JWT token validation schema with specific type

func (*ZodJWT[T]) MustStrictParse added in v0.4.0

func (z *ZodJWT[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodJWT[T]) StrictParse added in v0.4.0

func (z *ZodJWT[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodKSUID added in v0.3.0

type ZodKSUID[T StringConstraint] struct{ *ZodString[T] }

func Ksuid added in v0.3.0

func Ksuid(params ...any) *ZodKSUID[string]

func KsuidPtr added in v0.3.0

func KsuidPtr(params ...any) *ZodKSUID[*string]

func (*ZodKSUID[T]) MustStrictParse added in v0.4.0

func (z *ZodKSUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodKSUID[T]) StrictParse added in v0.4.0

func (z *ZodKSUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodLazy

type ZodLazy[T LazyConstraint] struct {
	// contains filtered or unexported fields
}

ZodLazy represents a lazy validation schema for recursive type definitions

func LazyAny added in v0.3.0

func LazyAny(getter func() any, params ...any) *ZodLazy[any]

LazyAny creates a lazy schema that defers evaluation until needed, enabling recursive type definitions

func LazyPtr added in v0.3.0

func LazyPtr(getter func() any, params ...any) *ZodLazy[*any]

LazyPtr creates a schema for *any lazy type

func LazyTyped added in v0.3.0

func LazyTyped[T LazyConstraint](getter func() any, params ...any) *ZodLazy[T]

LazyTyped is the underlying generic function for creating lazy schemas

func (*ZodLazy[T]) CloneFrom

func (z *ZodLazy[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodLazy[T]) Coerce

func (z *ZodLazy[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface - lazy schemas delegate to inner schema

func (*ZodLazy[T]) Default

func (z *ZodLazy[T]) Default(v any) *ZodLazy[T]

Default preserves the current generic type T

func (*ZodLazy[T]) DefaultFunc

func (z *ZodLazy[T]) DefaultFunc(fn func() any) *ZodLazy[T]

DefaultFunc preserves the current generic type T

func (*ZodLazy[T]) Describe added in v0.5.4

func (z *ZodLazy[T]) Describe(description string) *ZodLazy[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodLazy[T]) GetInternals

func (z *ZodLazy[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodLazy[T]) IsNilable added in v0.3.0

func (z *ZodLazy[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodLazy[T]) IsOptional added in v0.3.0

func (z *ZodLazy[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodLazy[T]) Meta added in v0.3.1

func (z *ZodLazy[T]) Meta(meta core.GlobalMeta) *ZodLazy[T]

Meta stores metadata for this lazy schema.

func (*ZodLazy[T]) MustParse

func (z *ZodLazy[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error

func (*ZodLazy[T]) MustStrictParse added in v0.4.0

func (z *ZodLazy[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodLazy[T]) Nilable

func (z *ZodLazy[T]) Nilable() *ZodLazy[*any]

Nilable allows the lazy schema to be nil, returns pointer type

func (*ZodLazy[T]) NonOptional added in v0.3.0

func (z *ZodLazy[T]) NonOptional() *ZodLazy[any]

NonOptional removes Optional flag and enforces non-nil value (any).

func (*ZodLazy[T]) Nullish

func (z *ZodLazy[T]) Nullish() *ZodLazy[*any]

Nullish combines optional and nilable modifiers, returns pointer type

func (*ZodLazy[T]) Optional

func (z *ZodLazy[T]) Optional() *ZodLazy[*any]

Optional allows the lazy schema to be nil, returns pointer type

func (*ZodLazy[T]) Parse

func (z *ZodLazy[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse validates and returns the parsed value using lazy evaluation

func (*ZodLazy[T]) ParseAny added in v0.3.0

func (z *ZodLazy[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodLazy[T]) Pipe

func (z *ZodLazy[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodLazy[T]) Prefault

func (z *ZodLazy[T]) Prefault(v any) *ZodLazy[T]

Prefault preserves the current generic type T

func (*ZodLazy[T]) PrefaultFunc

func (z *ZodLazy[T]) PrefaultFunc(fn func() any) *ZodLazy[T]

PrefaultFunc preserves the current generic type T

func (*ZodLazy[T]) Refine

func (z *ZodLazy[T]) Refine(fn func(T) bool, params ...any) *ZodLazy[T]

Refine applies custom validation function

func (*ZodLazy[T]) RefineAny

func (z *ZodLazy[T]) RefineAny(fn func(any) bool, params ...any) *ZodLazy[T]

RefineAny adds flexible custom validation logic

func (*ZodLazy[T]) StrictParse added in v0.4.0

func (z *ZodLazy[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

func (*ZodLazy[T]) Transform

func (z *ZodLazy[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using WrapFn pattern

func (*ZodLazy[T]) Unwrap

func (z *ZodLazy[T]) Unwrap() core.ZodType[any]

Unwrap resolves and returns the inner schema

type ZodLazyDef

type ZodLazyDef struct {
	core.ZodTypeDef
	Getter func() any // Schema getter function that returns any schema type
}

ZodLazyDef defines the configuration for lazy validation

type ZodLazyInternals

type ZodLazyInternals struct {
	core.ZodTypeInternals
	Def       *ZodLazyDef       // Schema definition
	Getter    func() any        // Schema getter function that returns any schema type
	InnerType core.ZodType[any] // Cached inner schema (converted to interface)
	Cached    bool              // Whether inner schema is cached
}

ZodLazyInternals contains lazy validator internal state

type ZodLazyTyped added in v0.3.0

type ZodLazyTyped[S ZodSchemaType] struct {
	*ZodLazy[any]
	// contains filtered or unexported fields
}

ZodLazyTyped is a type-safe wrapper that preserves the inner schema type

func Lazy

func Lazy[S ZodSchemaType](getter func() S, params ...any) *ZodLazyTyped[S]

Lazy creates a type-safe lazy schema with compile-time type checking. This allows for syntax like: Lazy[*ZodString[string]](func() *ZodString[string] { return String().Min(3) })

func (*ZodLazyTyped[S]) Default added in v0.3.0

func (z *ZodLazyTyped[S]) Default(v any) *ZodLazyTyped[S]

Default provides a default value for the lazy schema

func (*ZodLazyTyped[S]) GetInnerSchema added in v0.3.0

func (z *ZodLazyTyped[S]) GetInnerSchema() S

GetInnerSchema returns the inner schema with its original type

func (*ZodLazyTyped[S]) MustParse added in v0.3.0

func (z *ZodLazyTyped[S]) MustParse(input any, ctx ...*core.ParseContext) any

MustParse is the type-safe variant that panics on error

func (*ZodLazyTyped[S]) Nilable added in v0.3.0

func (z *ZodLazyTyped[S]) Nilable() *ZodLazy[*any]

Nilable creates a nilable version

func (*ZodLazyTyped[S]) NonOptional added in v0.3.0

func (z *ZodLazyTyped[S]) NonOptional() *ZodLazy[any]

NonOptional removes Optional flag and enforces non-nil value.

func (*ZodLazyTyped[S]) Optional added in v0.3.0

func (z *ZodLazyTyped[S]) Optional() *ZodLazy[*any]

Optional creates an optional version

func (*ZodLazyTyped[S]) Parse added in v0.3.0

func (z *ZodLazyTyped[S]) Parse(input any, ctx ...*core.ParseContext) (any, error)

Parse validates and returns the parsed value with type safety

func (*ZodLazyTyped[S]) Refine added in v0.3.0

func (z *ZodLazyTyped[S]) Refine(fn func(any) bool, params ...any) *ZodLazyTyped[S]

Refine applies custom validation with type safety

type ZodLiteral

type ZodLiteral[T comparable, R any] struct {
	// contains filtered or unexported fields
}

func Literal

func Literal[T comparable](value T, params ...any) *ZodLiteral[T, T]

func LiteralOf added in v0.3.0

func LiteralOf[T comparable](values []T, params ...any) *ZodLiteral[T, T]

func LiteralPtr added in v0.3.0

func LiteralPtr[T comparable](value T, params ...any) *ZodLiteral[T, *T]

LiteralPtr creates a literal schema for a single value with a pointer return type

func LiteralPtrOf added in v0.3.0

func LiteralPtrOf[T comparable](values []T, params ...any) *ZodLiteral[T, *T]

LiteralPtrOf creates a multi-value literal schema with a pointer return type

func LiteralTyped added in v0.3.0

func LiteralTyped[T comparable, R any](value T, params ...any) *ZodLiteral[T, R]

func (*ZodLiteral[T, R]) Contains added in v0.3.0

func (z *ZodLiteral[T, R]) Contains(v T) bool

Contains checks if a given value is one of the allowed literal values.

func (*ZodLiteral[T, R]) Default

func (z *ZodLiteral[T, R]) Default(v T) *ZodLiteral[T, R]

Default sets a default value for the schema.

func (*ZodLiteral[T, R]) DefaultFunc

func (z *ZodLiteral[T, R]) DefaultFunc(fn func() T) *ZodLiteral[T, R]

func (*ZodLiteral[T, R]) GetInternals

func (z *ZodLiteral[T, R]) GetInternals() *core.ZodTypeInternals

func (*ZodLiteral[T, R]) IsNilable added in v0.3.0

func (z *ZodLiteral[T, R]) IsNilable() bool

func (*ZodLiteral[T, R]) IsOptional added in v0.3.0

func (z *ZodLiteral[T, R]) IsOptional() bool

func (*ZodLiteral[T, R]) MustParse

func (z *ZodLiteral[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

func (*ZodLiteral[T, R]) MustParseAny added in v0.3.1

func (z *ZodLiteral[T, R]) MustParseAny(input any, ctx ...*core.ParseContext) any

func (*ZodLiteral[T, R]) MustStrictParse added in v0.4.0

func (z *ZodLiteral[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse is the strict mode variant that panics on error.

func (*ZodLiteral[T, R]) Nilable

func (z *ZodLiteral[T, R]) Nilable() *ZodLiteral[T, *T]

Nilable returns a new schema that allows the value to be nil. It changes the constraint type from R to *T.

func (*ZodLiteral[T, R]) Nullish

func (z *ZodLiteral[T, R]) Nullish() *ZodLiteral[T, *T]

Nullish combines optional and nilable modifiers.

func (*ZodLiteral[T, R]) Optional

func (z *ZodLiteral[T, R]) Optional() *ZodLiteral[T, *T]

Optional returns a new schema that allows the value to be nil. It changes the constraint type from R to *T.

func (*ZodLiteral[T, R]) Parse

func (z *ZodLiteral[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates the input value and returns a typed result. It leverages engine.ParsePrimitive so that all modifiers, checks, and transforms work consistently across the code-base.

func (*ZodLiteral[T, R]) ParseAny added in v0.3.0

func (z *ZodLiteral[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny is a zero-overhead wrapper around Parse and is used by reflection-based callers that don’t know the concrete type parameters at compile-time.

func (*ZodLiteral[T, R]) Prefault

func (z *ZodLiteral[T, R]) Prefault(v T) *ZodLiteral[T, R]

Prefault sets a fallback value if parsing fails.

func (*ZodLiteral[T, R]) PrefaultFunc

func (z *ZodLiteral[T, R]) PrefaultFunc(fn func() T) *ZodLiteral[T, R]

func (*ZodLiteral[T, R]) Refine

func (z *ZodLiteral[T, R]) Refine(fn func(T) bool, params ...any) *ZodLiteral[T, R]

Refine adds a custom validation check to the schema.

func (*ZodLiteral[T, R]) RefineAny

func (z *ZodLiteral[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodLiteral[T, R]

RefineAny adds a custom validation check to the schema, accepting `any`.

func (*ZodLiteral[T, R]) StrictParse added in v0.4.0

func (z *ZodLiteral[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching.

func (*ZodLiteral[T, R]) Value

func (z *ZodLiteral[T, R]) Value() T

Value returns the first literal value. Useful for single-value literals.

func (*ZodLiteral[T, R]) Values added in v0.3.0

func (z *ZodLiteral[T, R]) Values() []T

Values returns all literal values.

type ZodLiteralDef

type ZodLiteralDef[T comparable] struct {
	core.ZodTypeDef
	Values []T
}

ZodLiteralDef defines the structure of a literal schema

type ZodLiteralInternals

type ZodLiteralInternals[T comparable] struct {
	core.ZodTypeInternals
	Def *ZodLiteralDef[T]
}

ZodLiteralInternals holds the internal state of a literal schema

type ZodMAC added in v0.5.4

type ZodMAC[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodMAC represents a MAC address validation schema

func MAC added in v0.5.4

func MAC(params ...any) *ZodMAC[string]

MAC creates a MAC address schema with default colon delimiter

func MACPtr added in v0.5.4

func MACPtr(params ...any) *ZodMAC[*string]

MACPtr creates a MAC address schema for pointer types

func MACTyped added in v0.5.4

func MACTyped[T NetworkConstraint](delimiter string, params ...any) *ZodMAC[T]

MACTyped creates a MAC address schema with custom delimiter and type

func MACWithDelimiter added in v0.5.4

func MACWithDelimiter(delimiter string, params ...any) *ZodMAC[string]

MACWithDelimiter creates a MAC address schema with custom delimiter

func (*ZodMAC[T]) And added in v0.5.4

func (z *ZodMAC[T]) And(other any) *ZodIntersection[any, any]

func (*ZodMAC[T]) Coerce added in v0.5.4

func (z *ZodMAC[T]) Coerce(input any) (any, bool)

func (*ZodMAC[T]) Default added in v0.5.4

func (z *ZodMAC[T]) Default(v string) *ZodMAC[T]

func (*ZodMAC[T]) Describe added in v0.5.4

func (z *ZodMAC[T]) Describe(description string) *ZodMAC[T]

func (*ZodMAC[T]) GetInternals added in v0.5.4

func (z *ZodMAC[T]) GetInternals() *core.ZodTypeInternals

func (*ZodMAC[T]) IsNilable added in v0.5.4

func (z *ZodMAC[T]) IsNilable() bool

func (*ZodMAC[T]) IsOptional added in v0.5.4

func (z *ZodMAC[T]) IsOptional() bool

func (*ZodMAC[T]) MustParse added in v0.5.4

func (z *ZodMAC[T]) MustParse(input any, ctx ...*core.ParseContext) T

func (*ZodMAC[T]) MustStrictParse added in v0.5.4

func (z *ZodMAC[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

func (*ZodMAC[T]) Nilable added in v0.5.4

func (z *ZodMAC[T]) Nilable() *ZodMAC[*string]

func (*ZodMAC[T]) Optional added in v0.5.4

func (z *ZodMAC[T]) Optional() *ZodMAC[*string]

func (*ZodMAC[T]) Or added in v0.5.4

func (z *ZodMAC[T]) Or(other any) *ZodUnion[any, any]

func (*ZodMAC[T]) Parse added in v0.5.4

func (z *ZodMAC[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

func (*ZodMAC[T]) ParseAny added in v0.5.4

func (z *ZodMAC[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

func (*ZodMAC[T]) StrictParse added in v0.5.4

func (z *ZodMAC[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

type ZodMACDef added in v0.5.4

type ZodMACDef struct {
	core.ZodTypeDef
	Delimiter string // MAC address delimiter (default ":")
}

ZodMACDef defines the configuration for MAC address validation

type ZodMACInternals added in v0.5.4

type ZodMACInternals struct {
	core.ZodTypeInternals
	Def *ZodMACDef
}

ZodMACInternals contains MAC address validator internal state

func (*ZodMACInternals) Clone added in v0.5.4

Clone creates a deep copy of internals

type ZodMap

type ZodMap[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodMap represents a type-safe map validation schema with dual generic parameters T = base type (map[any]any), R = constraint type (map[any]any or *map[any]any)

func Map

func Map(keySchema, valueSchema any, paramArgs ...any) *ZodMap[map[any]any, map[any]any]

Map creates map schema with key and value validation - returns value constraint

func MapPtr added in v0.3.0

func MapPtr(keySchema, valueSchema any, paramArgs ...any) *ZodMap[map[any]any, *map[any]any]

MapPtr creates map schema with key and value validation - returns pointer constraint

func MapTyped added in v0.3.0

func MapTyped[T any, R any](keySchema, valueSchema any, paramArgs ...any) *ZodMap[T, R]

MapTyped creates typed map schema with generic constraints

func (*ZodMap[T, R]) Check

func (z *ZodMap[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodMap[T, R]

Check adds a custom validation function that can report multiple issues for map schema.

func (*ZodMap[T, R]) CloneFrom

func (z *ZodMap[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodMap[T, R]) Default

func (z *ZodMap[T, R]) Default(v T) *ZodMap[T, R]

Default preserves current constraint type R

func (*ZodMap[T, R]) DefaultFunc

func (z *ZodMap[T, R]) DefaultFunc(fn func() T) *ZodMap[T, R]

DefaultFunc preserves current constraint type R

func (*ZodMap[T, R]) Describe added in v0.5.4

func (z *ZodMap[T, R]) Describe(description string) *ZodMap[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodMap[T, R]) GetInternals

func (z *ZodMap[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodMap[T, R]) IsNilable added in v0.3.0

func (z *ZodMap[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodMap[T, R]) IsOptional added in v0.3.0

func (z *ZodMap[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodMap[T, R]) KeyType added in v0.3.1

func (z *ZodMap[T, R]) KeyType() any

KeyType returns the key schema for this map.

func (*ZodMap[T, R]) Max

func (z *ZodMap[T, R]) Max(maxLen int, params ...any) *ZodMap[T, R]

Max sets maximum number of entries

func (*ZodMap[T, R]) Meta added in v0.3.1

func (z *ZodMap[T, R]) Meta(meta core.GlobalMeta) *ZodMap[T, R]

Meta stores metadata for this map schema.

func (*ZodMap[T, R]) Min

func (z *ZodMap[T, R]) Min(minLen int, params ...any) *ZodMap[T, R]

Min sets minimum number of entries

func (*ZodMap[T, R]) MustParse

func (z *ZodMap[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodMap[T, R]) MustStrictParse added in v0.4.0

func (z *ZodMap[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure

func (*ZodMap[T, R]) Nilable

func (z *ZodMap[T, R]) Nilable() *ZodMap[T, *T]

Nilable allows nil values and returns pointer constraint

func (*ZodMap[T, R]) NonEmpty added in v0.5.4

func (z *ZodMap[T, R]) NonEmpty(params ...any) *ZodMap[T, R]

NonEmpty ensures map has at least one entry. This is a convenience method equivalent to Min(1).

func (*ZodMap[T, R]) NonOptional added in v0.3.0

func (z *ZodMap[T, R]) NonOptional() *ZodMap[T, T]

NonOptional removes Optional flag to require map value and returns base constraint type.

func (*ZodMap[T, R]) Nullish

func (z *ZodMap[T, R]) Nullish() *ZodMap[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodMap[T, R]) Optional

func (z *ZodMap[T, R]) Optional() *ZodMap[T, *T]

Optional creates optional map schema that returns pointer constraint

func (*ZodMap[T, R]) Overwrite added in v0.3.0

func (z *ZodMap[T, R]) Overwrite(transform func(R) R, params ...any) *ZodMap[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodMap[T, R]) Parse

func (z *ZodMap[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using direct validation approach Parse validates input using map-specific parsing logic with engine.ParseComplex

func (*ZodMap[T, R]) ParseAny added in v0.3.0

func (z *ZodMap[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodMap[T, R]) Pipe

func (z *ZodMap[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion. Map types implement direct extraction of T values for transformation.

func (*ZodMap[T, R]) Prefault

func (z *ZodMap[T, R]) Prefault(v T) *ZodMap[T, R]

Prefault provides fallback values on validation failure

func (*ZodMap[T, R]) PrefaultFunc

func (z *ZodMap[T, R]) PrefaultFunc(fn func() T) *ZodMap[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodMap[T, R]) Refine

func (z *ZodMap[T, R]) Refine(fn func(R) bool, params ...any) *ZodMap[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodMap[T, R]) RefineAny

func (z *ZodMap[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodMap[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodMap[T, R]) Size added in v0.3.0

func (z *ZodMap[T, R]) Size(exactLen int, params ...any) *ZodMap[T, R]

Size sets exact number of entries

func (*ZodMap[T, R]) StrictParse added in v0.4.0

func (z *ZodMap[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates input with compile-time type safety

func (*ZodMap[T, R]) Transform

func (z *ZodMap[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Map types implement direct extraction of T values for transformation.

func (*ZodMap[T, R]) ValueType added in v0.3.1

func (z *ZodMap[T, R]) ValueType() any

ValueType returns the value schema for this map.

func (*ZodMap[T, R]) With added in v0.5.4

func (z *ZodMap[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodMap[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodMapDef

type ZodMapDef struct {
	core.ZodTypeDef
	KeyType   any // The key schema (type-erased for flexibility)
	ValueType any // The value schema (type-erased for flexibility)
}

ZodMapDef defines the schema definition for map validation

type ZodMapInternals

type ZodMapInternals struct {
	core.ZodTypeInternals
	Def       *ZodMapDef // Schema definition reference
	KeyType   any        // Key schema for runtime validation
	ValueType any        // Value schema for runtime validation
}

ZodMapInternals contains the internal state for map schema

type ZodNanoID added in v0.3.0

type ZodNanoID[T StringConstraint] struct{ *ZodString[T] }

func Nanoid added in v0.3.0

func Nanoid(params ...any) *ZodNanoID[string]

func NanoidPtr added in v0.3.0

func NanoidPtr(params ...any) *ZodNanoID[*string]

func (*ZodNanoID[T]) MustStrictParse added in v0.4.0

func (z *ZodNanoID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodNanoID[T]) StrictParse added in v0.4.0

func (z *ZodNanoID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodNever

type ZodNever[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodNever represents a never validation schema that always fails validation

func Never

func Never(paramArgs ...any) *ZodNever[any, any]

Never creates never schema that always fails validation - returns value constraint

func NeverPtr added in v0.3.0

func NeverPtr(paramArgs ...any) *ZodNever[any, *any]

NeverPtr creates never schema that always fails validation - returns pointer constraint

func NeverTyped added in v0.3.0

func NeverTyped[T any, R any](paramArgs ...any) *ZodNever[T, R]

NeverTyped creates typed never schema with generic constraints

func (*ZodNever[T, R]) CloneFrom

func (z *ZodNever[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodNever[T, R]) Default added in v0.3.0

func (z *ZodNever[T, R]) Default(value T) *ZodNever[T, R]

Default sets a default value - preserves current constraint type

func (*ZodNever[T, R]) DefaultFunc added in v0.3.0

func (z *ZodNever[T, R]) DefaultFunc(fn func() T) *ZodNever[T, R]

DefaultFunc sets a default value function - preserves current constraint type

func (*ZodNever[T, R]) Describe added in v0.5.4

func (z *ZodNever[T, R]) Describe(description string) *ZodNever[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodNever[T, R]) GetInternals

func (z *ZodNever[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal configuration

func (*ZodNever[T, R]) IsNilable added in v0.3.0

func (z *ZodNever[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodNever[T, R]) IsOptional added in v0.3.0

func (z *ZodNever[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodNever[T, R]) Meta added in v0.3.1

func (z *ZodNever[T, R]) Meta(meta core.GlobalMeta) *ZodNever[T, R]

Meta stores metadata for this never schema.

func (*ZodNever[T, R]) MustParse

func (z *ZodNever[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodNever[T, R]) MustStrictParse added in v0.4.0

func (z *ZodNever[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodNever[T, R]) Nilable

func (z *ZodNever[T, R]) Nilable() *ZodNever[T, *T]

Nilable makes the never nilable (allows nil) - returns pointer constraint

func (*ZodNever[T, R]) Nullish

func (z *ZodNever[T, R]) Nullish() *ZodNever[T, *T]

Nullish makes the never both optional and nilable - returns pointer constraint

func (*ZodNever[T, R]) Optional

func (z *ZodNever[T, R]) Optional() *ZodNever[T, *T]

Optional makes the never optional (allows nil) - returns pointer constraint

func (*ZodNever[T, R]) Parse

func (z *ZodNever[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates the input value with never logic using unified engine parsing

func (*ZodNever[T, R]) ParseAny added in v0.3.0

func (z *ZodNever[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodNever[T, R]) Pipe

func (z *ZodNever[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a validation pipeline using WrapFn pattern (first stage will be Never)

func (*ZodNever[T, R]) Prefault added in v0.3.0

func (z *ZodNever[T, R]) Prefault(value T) *ZodNever[T, R]

Prefault sets a prefault (fallback) value - preserves current constraint type

func (*ZodNever[T, R]) PrefaultFunc added in v0.3.0

func (z *ZodNever[T, R]) PrefaultFunc(fn func() T) *ZodNever[T, R]

PrefaultFunc keeps the current generic type R.

func (*ZodNever[T, R]) Refine

func (z *ZodNever[T, R]) Refine(fn func(R) bool, params ...any) *ZodNever[T, R]

Refine adds a validation function with constraint type R

func (*ZodNever[T, R]) RefineAny

func (z *ZodNever[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodNever[T, R]

RefineAny adds flexible validation with any type

func (*ZodNever[T, R]) StrictParse added in v0.4.0

func (z *ZodNever[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodNever[T, R]) Transform

func (z *ZodNever[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using WrapFn pattern (note: rarely called due to Never's nature)

func (*ZodNever[T, R]) Unwrap

func (z *ZodNever[T, R]) Unwrap() *ZodNever[T, R]

Unwrap returns the schema itself for compatibility

type ZodNeverDef

type ZodNeverDef struct {
	core.ZodTypeDef
}

ZodNeverDef defines the structure for never validation schemas

type ZodNeverInternals

type ZodNeverInternals struct {
	core.ZodTypeInternals
	Def *ZodNeverDef // Schema definition
}

ZodNeverInternals provides internal state for never schemas

type ZodNil

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

ZodNil represents a nil validation schema with type safety

func Nil

func Nil(params ...any) *ZodNil[any]

Nil creates a nil schema following Zod TypeScript v4 pattern Usage:

Nil()                    // no parameters
Nil("custom error")      // string shorthand
Nil(SchemaParams{...})   // full parameters

func NilPtr added in v0.3.0

func NilPtr(params ...any) *ZodNil[*any]

NilPtr creates a schema for *any

func NilTyped added in v0.3.0

func NilTyped[T any](params ...any) *ZodNil[T]

NilTyped is the underlying generic function for creating nil schemas allowing for explicit type parameterization

func (*ZodNil[T]) CloneFrom

func (z *ZodNil[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodNil[T]) Default

func (z *ZodNil[T]) Default(v any) *ZodNil[T]

Default keeps the current generic type T.

func (*ZodNil[T]) DefaultFunc

func (z *ZodNil[T]) DefaultFunc(fn func() any) *ZodNil[T]

DefaultFunc keeps the current generic type T.

func (*ZodNil[T]) Describe added in v0.5.4

func (z *ZodNil[T]) Describe(description string) *ZodNil[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodNil[T]) GetInternals

func (z *ZodNil[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodNil[T]) IsNilable added in v0.3.0

func (z *ZodNil[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodNil[T]) IsOptional added in v0.3.0

func (z *ZodNil[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodNil[T]) Meta added in v0.3.1

func (z *ZodNil[T]) Meta(meta core.GlobalMeta) *ZodNil[T]

Meta stores metadata for this nil schema.

func (*ZodNil[T]) MustParse

func (z *ZodNil[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error.

func (*ZodNil[T]) MustParseAny added in v0.4.0

func (z *ZodNil[T]) MustParseAny(input any, ctx ...*core.ParseContext) any

MustParseAny is the any-type variant that panics on error.

func (*ZodNil[T]) MustStrictParse added in v0.4.0

func (z *ZodNil[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodNil[T]) Nilable

func (z *ZodNil[T]) Nilable() *ZodNil[*any]

Nilable always returns *any because the value may be nil.

func (*ZodNil[T]) Nullish

func (z *ZodNil[T]) Nullish() *ZodNil[*any]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodNil[T]) Optional

func (z *ZodNil[T]) Optional() *ZodNil[*any]

Optional always returns *any because the optional value may be nil or missing.

func (*ZodNil[T]) Parse

func (z *ZodNil[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety Nil type uses the standard ParsePrimitive with custom validator and converter

func (*ZodNil[T]) ParseAny added in v0.3.0

func (z *ZodNil[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodNil[T]) Pipe

func (z *ZodNil[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodNil[T]) Prefault

func (z *ZodNil[T]) Prefault(v any) *ZodNil[T]

Prefault keeps the current generic type T.

func (*ZodNil[T]) PrefaultFunc

func (z *ZodNil[T]) PrefaultFunc(fn func() any) *ZodNil[T]

PrefaultFunc keeps the current generic type T.

func (*ZodNil[T]) Refine

func (z *ZodNil[T]) Refine(fn func(T) bool, params ...any) *ZodNil[T]

Refine applies a custom validation function that matches the schema's output type T. The callback will be executed even when the value is nil (for *any schemas) to align with Zod v4 semantics.

func (*ZodNil[T]) RefineAny

func (z *ZodNil[T]) RefineAny(fn func(any) bool, params ...any) *ZodNil[T]

RefineAny adds flexible custom validation logic

func (*ZodNil[T]) StrictParse added in v0.4.0

func (z *ZodNil[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodNil[T]) Transform

func (z *ZodNil[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using WrapFn pattern

type ZodNilDef

type ZodNilDef struct {
	core.ZodTypeDef
}

ZodNilDef defines the configuration for nil validation

type ZodNilInternals

type ZodNilInternals struct {
	core.ZodTypeInternals
	Def *ZodNilDef // Schema definition
}

ZodNilInternals contains nil validator internal state

type ZodObject

type ZodObject[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodObject represents a type-safe object validation schema

func LooseObject

func LooseObject(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]

LooseObject creates loose object schema with default types

func LooseObjectPtr added in v0.3.0

func LooseObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]

LooseObjectPtr creates loose object schema with pointer constraint

func Object

func Object(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]

Object creates object schema with default types (map[string]any, map[string]any)

func ObjectPtr added in v0.3.0

func ObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]

ObjectPtr creates object schema with pointer constraint

func ObjectTyped added in v0.3.0

func ObjectTyped[T any, R any](shape core.ObjectSchema, params ...any) *ZodObject[T, R]

ObjectTyped creates a typed object schema with explicit type parameters

func StrictObject

func StrictObject(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]

StrictObject creates strict object schema with default types

func StrictObjectPtr added in v0.3.0

func StrictObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]

StrictObjectPtr creates strict object schema with pointer constraint

func (*ZodObject[T, R]) And added in v0.5.4

func (z *ZodObject[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Object(map[string]any{"name": gozod.String()}).
    And(gozod.Object(map[string]any{"age": gozod.Int()}))
result, _ := schema.Parse(map[string]any{"name": "John", "age": 30})

func (*ZodObject[T, R]) Catchall

func (z *ZodObject[T, R]) Catchall(catchallSchema core.ZodSchema) *ZodObject[T, R]

Catchall sets a schema for unknown keys

func (*ZodObject[T, R]) Check

func (z *ZodObject[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodObject[T, R]

Check adds a custom validation function that can report multiple issues for object schema.

func (*ZodObject[T, R]) CloneFrom

func (z *ZodObject[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodObject[T, R]) Default

func (z *ZodObject[T, R]) Default(v T) *ZodObject[T, R]

Default preserves current type

func (*ZodObject[T, R]) DefaultFunc

func (z *ZodObject[T, R]) DefaultFunc(fn func() T) *ZodObject[T, R]

DefaultFunc preserves current type

func (*ZodObject[T, R]) Describe added in v0.5.4

func (z *ZodObject[T, R]) Describe(description string) *ZodObject[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodObject[T, R]) Extend

func (z *ZodObject[T, R]) Extend(augmentation core.ObjectSchema, params ...any) (*ZodObject[T, R], error)

Extend creates a new object by extending with additional fields. Returns error if the schema has refinements AND augmentation overlaps existing keys. Zod v4 compatible: .extend() throws when overwriting keys on refined schemas. See: .reference/zod/packages/zod/src/v4/core/util.ts:651-677

func (*ZodObject[T, R]) GetCatchall added in v0.3.1

func (z *ZodObject[T, R]) GetCatchall() core.ZodSchema

GetCatchall returns the catchall schema for JSON Schema conversion

func (*ZodObject[T, R]) GetInternals

func (z *ZodObject[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodObject[T, R]) GetUnknownKeys added in v0.3.1

func (z *ZodObject[T, R]) GetUnknownKeys() ObjectMode

GetUnknownKeys returns the unknown keys handling mode for JSON Schema conversion

func (*ZodObject[T, R]) IsNilable added in v0.3.0

func (z *ZodObject[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodObject[T, R]) IsOptional added in v0.3.0

func (z *ZodObject[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodObject[T, R]) Keyof

func (z *ZodObject[T, R]) Keyof() *ZodEnum[string, string]

Keyof returns a string literal schema of all keys

func (*ZodObject[T, R]) Max added in v0.3.0

func (z *ZodObject[T, R]) Max(maxLen int, params ...any) *ZodObject[T, R]

Max sets maximum number of fields

func (*ZodObject[T, R]) Merge

func (z *ZodObject[T, R]) Merge(other *ZodObject[T, R], params ...any) *ZodObject[T, R]

Merge combines two object schemas. Zod v4 compatible: .merge() clears all checks/refinements. See: .reference/zod/packages/zod/src/v4/core/util.ts:693-707

func (*ZodObject[T, R]) Meta added in v0.3.1

func (z *ZodObject[T, R]) Meta(meta core.GlobalMeta) *ZodObject[T, R]

Meta attaches GlobalMeta to this object schema via the global registry.

func (*ZodObject[T, R]) Min added in v0.3.0

func (z *ZodObject[T, R]) Min(minLen int, params ...any) *ZodObject[T, R]

Min sets minimum number of fields

func (*ZodObject[T, R]) MustOmit added in v0.5.4

func (z *ZodObject[T, R]) MustOmit(keys []string, params ...any) *ZodObject[T, R]

MustOmit is like Omit but panics on error.

func (*ZodObject[T, R]) MustParse

func (z *ZodObject[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodObject[T, R]) MustPick added in v0.5.4

func (z *ZodObject[T, R]) MustPick(keys []string, params ...any) *ZodObject[T, R]

MustPick is like Pick but panics on error.

func (*ZodObject[T, R]) MustStrictParse added in v0.4.0

func (z *ZodObject[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodObject[T, R]) Nilable

func (z *ZodObject[T, R]) Nilable() *ZodObject[T, *T]

Nilable allows nil values

func (*ZodObject[T, R]) NonOptional added in v0.3.0

func (z *ZodObject[T, R]) NonOptional() *ZodObject[T, T]

NonOptional removes the optional flag and enforces non-nil value type. It returns a schema whose constraint type is the base value (T), mirroring the behaviour of .Optional().NonOptional() chain in TypeScript Zod.

func (*ZodObject[T, R]) Nullish added in v0.3.0

func (z *ZodObject[T, R]) Nullish() *ZodObject[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodObject[T, R]) Omit

func (z *ZodObject[T, R]) Omit(keys []string, params ...any) (*ZodObject[T, R], error)

Omit creates a new object excluding specified keys. Returns error if any key does not exist or schema contains refinements. Zod v4 compatible: throws on refinements or unrecognized keys.

func (*ZodObject[T, R]) Optional

func (z *ZodObject[T, R]) Optional() *ZodObject[T, *T]

Optional creates optional object schema

func (*ZodObject[T, R]) Or added in v0.5.4

func (z *ZodObject[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Object(map[string]any{"type": gozod.Literal("a")}).
    Or(gozod.Object(map[string]any{"type": gozod.Literal("b")}))

func (*ZodObject[T, R]) Overwrite added in v0.3.0

func (z *ZodObject[T, R]) Overwrite(transform func(R) R, params ...any) *ZodObject[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodObject[T, R]) Parse

func (z *ZodObject[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using object-specific parsing logic with engine.ParseComplex

func (*ZodObject[T, R]) ParseAny added in v0.3.0

func (z *ZodObject[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodObject[T, R]) Partial

func (z *ZodObject[T, R]) Partial(keys ...[]string) *ZodObject[T, R]

Partial makes all fields optional

func (*ZodObject[T, R]) Passthrough

func (z *ZodObject[T, R]) Passthrough() *ZodObject[T, R]

Passthrough sets passthrough mode (unknown keys are allowed)

func (*ZodObject[T, R]) Pick

func (z *ZodObject[T, R]) Pick(keys []string, params ...any) (*ZodObject[T, R], error)

Pick creates a new object with only specified keys. Returns error if any key does not exist or schema contains refinements. Zod v4 compatible: throws on refinements or unrecognized keys.

func (*ZodObject[T, R]) Pipe

func (z *ZodObject[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodObject[T, R]) Prefault

func (z *ZodObject[T, R]) Prefault(v T) *ZodObject[T, R]

Prefault provides fallback values on validation failure

func (*ZodObject[T, R]) PrefaultFunc

func (z *ZodObject[T, R]) PrefaultFunc(fn func() T) *ZodObject[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodObject[T, R]) Properties added in v0.3.1

func (z *ZodObject[T, R]) Properties() core.ObjectSchema

Properties is an alias for Shape(), returning the object's field schemas. This is included for alignment with documentation and developer convenience.

func (*ZodObject[T, R]) Property added in v0.3.0

func (z *ZodObject[T, R]) Property(key string, schema core.ZodSchema, params ...any) *ZodObject[T, R]

Property validates a specific property using the provided schema

func (*ZodObject[T, R]) Refine

func (z *ZodObject[T, R]) Refine(fn func(R) bool, params ...any) *ZodObject[T, R]

Refine applies type-safe validation using constraint type. Schemas with refinements cannot use Pick/Omit (Zod v4 compatible).

func (*ZodObject[T, R]) RefineAny

func (z *ZodObject[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodObject[T, R]

RefineAny provides flexible validation without type conversion. Schemas with refinements cannot use Pick/Omit (Zod v4 compatible).

func (*ZodObject[T, R]) Required

func (z *ZodObject[T, R]) Required(fields ...[]string) *ZodObject[T, R]

Required makes all fields required (opposite of Partial)

func (*ZodObject[T, R]) SafeExtend added in v0.5.4

func (z *ZodObject[T, R]) SafeExtend(augmentation core.ObjectSchema, params ...any) *ZodObject[T, R]

SafeExtend creates a new object by extending with additional fields without checking refinements. Use this when you explicitly want to overwrite fields on a refined schema. Zod v4 compatible: .safeExtend() bypasses the refinement check. See: .reference/zod/packages/zod/src/v4/core/util.ts:679-691

func (*ZodObject[T, R]) Shape

func (z *ZodObject[T, R]) Shape() core.ObjectSchema

Shape returns the object shape (field schemas)

func (*ZodObject[T, R]) Size added in v0.3.0

func (z *ZodObject[T, R]) Size(exactLen int, params ...any) *ZodObject[T, R]

Size sets exact number of fields

func (*ZodObject[T, R]) Strict

func (z *ZodObject[T, R]) Strict() *ZodObject[T, R]

Strict sets strict mode (no unknown keys allowed)

func (*ZodObject[T, R]) StrictParse added in v0.4.0

func (z *ZodObject[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates input with compile-time type safety and enhanced performance. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodObject[T, R]) Strip

func (z *ZodObject[T, R]) Strip() *ZodObject[T, R]

Strip sets strip mode (unknown keys are removed)

func (*ZodObject[T, R]) Transform

func (z *ZodObject[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates a type-safe transformation using WrapFn pattern

func (*ZodObject[T, R]) With added in v0.5.4

func (z *ZodObject[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodObject[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodObjectDef

type ZodObjectDef struct {
	core.ZodTypeDef
	Shape       core.ObjectSchema // Field schemas
	Catchall    core.ZodSchema    // Schema for unrecognized keys
	UnknownKeys ObjectMode        // How to handle unknown keys
}

ZodObjectDef defines the schema definition for object validation

type ZodObjectInternals

type ZodObjectInternals struct {
	core.ZodTypeInternals
	Def                *ZodObjectDef     // Schema definition reference
	Shape              core.ObjectSchema // Field schemas for runtime validation
	Catchall           core.ZodSchema    // Catchall schema for unknown fields
	UnknownKeys        ObjectMode        // Validation mode
	IsPartial          bool              // Whether this is a partial object (all fields optional)
	PartialExceptions  map[string]bool   // Fields that should remain required in partial mode
	HasUserRefinements bool              // Whether user has added refinements via Refine/RefineAny/SuperRefine
}

ZodObjectInternals contains the internal state for object schema

type ZodRecord

type ZodRecord[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodRecord represents a type-safe record validation schema with dual generic parameters T = base type (map[string]any), R = constraint type (map[string]any or *map[string]any)

func LooseRecord added in v0.5.4

func LooseRecord(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]

LooseRecord creates a record schema that passes through non-matching keys unchanged. Unlike regular Record which errors on keys that don't match the key schema, LooseRecord preserves non-matching keys without validation.

This is particularly useful for pattern-based key validation where you want to: - Validate keys matching a specific pattern - Preserve all other keys unchanged

TypeScript Zod v4 equivalent: z.looseRecord(keySchema, valueSchema)

Example:

// Only validate keys starting with "S_"
schema := LooseRecord(String().Regex(`^S_`), String())
result, _ := schema.Parse(map[string]any{"S_name": "John", "other": 123})
// Result: {"S_name": "John", "other": 123} - "other" key is preserved

func LooseRecordPtr added in v0.5.4

func LooseRecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]

LooseRecordPtr creates a loose record schema returning pointer constraint

func PartialRecord

func PartialRecord(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]

PartialRecord creates a record schema that skips exhaustive key checks (equivalent to Zod's partialRecord)

func PartialRecordPtr added in v0.3.1

func PartialRecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]

PartialRecordPtr variant returning pointer constraint

func Record

func Record(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]

Record creates record schema with key schema and value schema - returns value constraint

func RecordPtr added in v0.3.0

func RecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]

RecordPtr creates record schema returning pointer constraint

func RecordTyped added in v0.3.0

func RecordTyped[T any, R any](keySchema, valueSchema any, paramArgs ...any) *ZodRecord[T, R]

RecordTyped creates typed record schema with generic constraints

func (*ZodRecord[T, R]) Check added in v0.3.0

func (z *ZodRecord[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodRecord[T, R]

Check adds a custom validation function that can report multiple issues for record schema.

func (*ZodRecord[T, R]) CloneFrom

func (z *ZodRecord[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodRecord[T, R]) Default

func (z *ZodRecord[T, R]) Default(v T) *ZodRecord[T, R]

Default preserves current constraint type R

func (*ZodRecord[T, R]) DefaultFunc

func (z *ZodRecord[T, R]) DefaultFunc(fn func() T) *ZodRecord[T, R]

DefaultFunc preserves current constraint type R

func (*ZodRecord[T, R]) Describe added in v0.5.4

func (z *ZodRecord[T, R]) Describe(description string) *ZodRecord[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodRecord[T, R]) GetInternals

func (z *ZodRecord[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodRecord[T, R]) IsLoose added in v0.5.4

func (z *ZodRecord[T, R]) IsLoose() bool

IsLoose returns true if this is a loose record (non-matching keys pass through)

func (*ZodRecord[T, R]) IsNilable added in v0.3.0

func (z *ZodRecord[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodRecord[T, R]) IsOptional added in v0.3.0

func (z *ZodRecord[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodRecord[T, R]) KeyType added in v0.3.1

func (z *ZodRecord[T, R]) KeyType() any

KeyType returns the key schema for this record, which is always a string.

func (*ZodRecord[T, R]) Max added in v0.3.0

func (z *ZodRecord[T, R]) Max(maxLen int, params ...any) *ZodRecord[T, R]

Max sets maximum number of entries

func (*ZodRecord[T, R]) Meta added in v0.3.1

func (z *ZodRecord[T, R]) Meta(meta core.GlobalMeta) *ZodRecord[T, R]

Meta stores metadata for this record schema.

func (*ZodRecord[T, R]) Min added in v0.3.0

func (z *ZodRecord[T, R]) Min(minLen int, params ...any) *ZodRecord[T, R]

Min sets minimum number of entries

func (*ZodRecord[T, R]) MustParse

func (z *ZodRecord[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodRecord[T, R]) MustStrictParse added in v0.4.0

func (z *ZodRecord[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse is the variant that panics on error

func (*ZodRecord[T, R]) Nilable

func (z *ZodRecord[T, R]) Nilable() *ZodRecord[T, *T]

Nilable allows nil values and returns pointer constraint

func (*ZodRecord[T, R]) NonOptional added in v0.3.0

func (z *ZodRecord[T, R]) NonOptional() *ZodRecord[T, T]

NonOptional removes Optional flag and enforces record presence.

func (*ZodRecord[T, R]) Nullish

func (z *ZodRecord[T, R]) Nullish() *ZodRecord[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodRecord[T, R]) Optional

func (z *ZodRecord[T, R]) Optional() *ZodRecord[T, *T]

Optional creates optional record schema that returns pointer constraint

func (*ZodRecord[T, R]) Overwrite added in v0.3.0

func (z *ZodRecord[T, R]) Overwrite(transform func(R) R, params ...any) *ZodRecord[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodRecord[T, R]) Parse

func (z *ZodRecord[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using unified ParseComplex API

func (*ZodRecord[T, R]) ParseAny added in v0.3.0

func (z *ZodRecord[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodRecord[T, R]) Partial added in v0.5.5

func (z *ZodRecord[T, R]) Partial() *ZodRecord[T, R]

Partial makes all record values optional by skipping exhaustive key checks. When a record has an exhaustive key schema (like Enum or Literal), Partial() allows missing keys instead of requiring all keys to be present.

TypeScript Zod v4 equivalent: z.partialRecord(keySchema, valueSchema)

Example:

keys := gozod.Enum([]string{"id", "name", "email"})
// Regular record requires all keys
schema := gozod.Record(keys, gozod.String())
_, err := schema.Parse(map[string]any{"id": "1"}) // Error: missing "name" and "email"

// Partial record allows missing keys
partialSchema := schema.Partial()
result, _ := partialSchema.Parse(map[string]any{"id": "1"}) // OK

func (*ZodRecord[T, R]) Pipe

func (z *ZodRecord[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

func (*ZodRecord[T, R]) Prefault

func (z *ZodRecord[T, R]) Prefault(v T) *ZodRecord[T, R]

Prefault provides fallback values on validation failure

func (*ZodRecord[T, R]) PrefaultFunc

func (z *ZodRecord[T, R]) PrefaultFunc(fn func() T) *ZodRecord[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodRecord[T, R]) Refine

func (z *ZodRecord[T, R]) Refine(fn func(R) bool, params ...any) *ZodRecord[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodRecord[T, R]) RefineAny

func (z *ZodRecord[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodRecord[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodRecord[T, R]) Size added in v0.3.0

func (z *ZodRecord[T, R]) Size(exactLen int, params ...any) *ZodRecord[T, R]

Size sets exact number of entries

func (*ZodRecord[T, R]) StrictParse added in v0.4.0

func (z *ZodRecord[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodRecord[T, R]) Transform

func (z *ZodRecord[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Record types implement direct extraction of T values for transformation.

func (*ZodRecord[T, R]) ValueType added in v0.3.1

func (z *ZodRecord[T, R]) ValueType() any

ValueType returns the value schema for JSON Schema conversion

func (*ZodRecord[T, R]) With added in v0.5.4

func (z *ZodRecord[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodRecord[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodRecordDef

type ZodRecordDef struct {
	core.ZodTypeDef
	KeyType   any // The key schema (type-erased for flexibility)
	ValueType any // The value schema (type-erased for flexibility)
}

ZodRecordDef defines the schema definition for record validation

type ZodRecordInternals

type ZodRecordInternals struct {
	core.ZodTypeInternals
	Def       *ZodRecordDef // Schema definition reference
	KeyType   any           // Key schema for runtime validation
	ValueType any           // Value schema for runtime validation
	Loose     bool          // Loose mode: pass through non-matching keys unchanged
}

ZodRecordInternals contains the internal state for record schema

type ZodSchemaType added in v0.3.0

type ZodSchemaType interface {
	GetInternals() *core.ZodTypeInternals
}

ZodSchemaType represents any Zod schema type that implements the basic interface

type ZodSet added in v0.5.5

type ZodSet[T comparable, R any] struct {
	// contains filtered or unexported fields
}

ZodSet represents a type-safe set validation schema with dual generic parameters T: element type (must be comparable), R: constraint type (map[T]struct{} or *map[T]struct{})

func Set added in v0.5.5

func Set[T comparable](valueSchema any, paramArgs ...any) *ZodSet[T, map[T]struct{}]

Set creates set schema with element validation (returns value constraint) In Go, sets are represented as map[T]struct{} where T must be comparable. TypeScript Zod v4 equivalent: z.set(schema)

func SetPtr added in v0.5.5

func SetPtr[T comparable](valueSchema any, paramArgs ...any) *ZodSet[T, *map[T]struct{}]

SetPtr creates set schema with pointer constraint (returns pointer constraint)

func SetTyped added in v0.5.5

func SetTyped[T comparable, R any](valueSchema any, paramArgs ...any) *ZodSet[T, R]

SetTyped creates set schema with explicit constraint type (universal constructor)

func (*ZodSet[T, R]) And added in v0.5.5

func (z *ZodSet[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. TypeScript Zod v4 equivalent: schema.and(other)

func (*ZodSet[T, R]) Check added in v0.5.5

func (z *ZodSet[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSet[T, R]

Check adds a custom validation function for set schema that can push multiple issues.

func (*ZodSet[T, R]) CloneFrom added in v0.5.5

func (z *ZodSet[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodSet[T, R]) Default added in v0.5.5

func (z *ZodSet[T, R]) Default(v map[T]struct{}) *ZodSet[T, R]

Default preserves current constraint type

func (*ZodSet[T, R]) DefaultFunc added in v0.5.5

func (z *ZodSet[T, R]) DefaultFunc(fn func() map[T]struct{}) *ZodSet[T, R]

DefaultFunc preserves current constraint type

func (*ZodSet[T, R]) Describe added in v0.5.5

func (z *ZodSet[T, R]) Describe(description string) *ZodSet[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodSet[T, R]) GetInternals added in v0.5.5

func (z *ZodSet[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodSet[T, R]) IsNilable added in v0.5.5

func (z *ZodSet[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodSet[T, R]) IsOptional added in v0.5.5

func (z *ZodSet[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodSet[T, R]) Max added in v0.5.5

func (z *ZodSet[T, R]) Max(maxLen int, params ...any) *ZodSet[T, R]

Max sets maximum number of elements

func (*ZodSet[T, R]) Meta added in v0.5.5

func (z *ZodSet[T, R]) Meta(meta core.GlobalMeta) *ZodSet[T, R]

Meta stores metadata for this set schema in the global registry.

func (*ZodSet[T, R]) Min added in v0.5.5

func (z *ZodSet[T, R]) Min(minLen int, params ...any) *ZodSet[T, R]

Min sets minimum number of elements

func (*ZodSet[T, R]) MustParse added in v0.5.5

func (z *ZodSet[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodSet[T, R]) MustStrictParse added in v0.5.5

func (z *ZodSet[T, R]) MustStrictParse(input map[T]struct{}, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure.

func (*ZodSet[T, R]) Nilable added in v0.5.5

func (z *ZodSet[T, R]) Nilable() *ZodSet[T, *map[T]struct{}]

Nilable allows nil values (always returns pointer constraint)

func (*ZodSet[T, R]) NonEmpty added in v0.5.5

func (z *ZodSet[T, R]) NonEmpty(params ...any) *ZodSet[T, R]

NonEmpty ensures set has at least one element TypeScript Zod v4 equivalent: z.set(...).nonempty()

func (*ZodSet[T, R]) NonOptional added in v0.5.5

func (z *ZodSet[T, R]) NonOptional() *ZodSet[T, map[T]struct{}]

NonOptional removes Optional flag and enforces non-nil set constraint.

func (*ZodSet[T, R]) Nullish added in v0.5.5

func (z *ZodSet[T, R]) Nullish() *ZodSet[T, *map[T]struct{}]

Nullish combines optional and nilable modifiers (always returns pointer constraint)

func (*ZodSet[T, R]) Optional added in v0.5.5

func (z *ZodSet[T, R]) Optional() *ZodSet[T, *map[T]struct{}]

Optional creates optional set schema (always returns pointer constraint)

func (*ZodSet[T, R]) Or added in v0.5.5

func (z *ZodSet[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. TypeScript Zod v4 equivalent: schema.or(other)

func (*ZodSet[T, R]) Overwrite added in v0.5.5

func (z *ZodSet[T, R]) Overwrite(transform func(R) R, params ...any) *ZodSet[T, R]

Overwrite transforms set value while keeping the same type

func (*ZodSet[T, R]) Parse added in v0.5.5

func (z *ZodSet[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using set-specific parsing logic with type safety

func (*ZodSet[T, R]) ParseAny added in v0.5.5

func (z *ZodSet[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios.

func (*ZodSet[T, R]) Pipe added in v0.5.5

func (z *ZodSet[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern.

func (*ZodSet[T, R]) Prefault added in v0.5.5

func (z *ZodSet[T, R]) Prefault(v map[T]struct{}) *ZodSet[T, R]

Prefault provides fallback values on validation failure (preserves constraint type)

func (*ZodSet[T, R]) PrefaultFunc added in v0.5.5

func (z *ZodSet[T, R]) PrefaultFunc(fn func() map[T]struct{}) *ZodSet[T, R]

PrefaultFunc provides dynamic fallback values (preserves constraint type)

func (*ZodSet[T, R]) Refine added in v0.5.5

func (z *ZodSet[T, R]) Refine(fn func(R) bool, params ...any) *ZodSet[T, R]

Refine adds type-safe custom validation with automatic constraint type matching

func (*ZodSet[T, R]) RefineAny added in v0.5.5

func (z *ZodSet[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodSet[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodSet[T, R]) Size added in v0.5.5

func (z *ZodSet[T, R]) Size(exactLen int, params ...any) *ZodSet[T, R]

Size sets exact number of elements

func (*ZodSet[T, R]) StrictParse added in v0.5.5

func (z *ZodSet[T, R]) StrictParse(input map[T]struct{}, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching.

func (*ZodSet[T, R]) Transform added in v0.5.5

func (z *ZodSet[T, R]) Transform(fn func(R, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern.

func (*ZodSet[T, R]) ValueType added in v0.5.5

func (z *ZodSet[T, R]) ValueType() any

ValueType returns the value schema for this set

func (*ZodSet[T, R]) With added in v0.5.5

func (z *ZodSet[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSet[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodSetDef added in v0.5.5

type ZodSetDef struct {
	core.ZodTypeDef
	ValueType any // The value schema (type-erased for flexibility)
}

ZodSetDef defines the schema definition for set validation. In Go, sets are idiomatically represented as map[T]struct{}.

type ZodSetInternals added in v0.5.5

type ZodSetInternals[T comparable] struct {
	core.ZodTypeInternals
	Def       *ZodSetDef // Schema definition reference
	ValueType any        // Value schema for runtime validation
}

ZodSetInternals contains the internal state for set schema

type ZodSlice

type ZodSlice[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodSlice represents a type-safe slice validation schema with dual generic parameters T: element type, R: constraint type ([]T or *[]T)

func Slice

func Slice[T any](elementSchema any, paramArgs ...any) *ZodSlice[T, []T]

Slice creates slice schema with element validation (returns value constraint)

func SlicePtr added in v0.3.0

func SlicePtr[T any](elementSchema any, paramArgs ...any) *ZodSlice[T, *[]T]

SlicePtr creates slice schema with pointer constraint (returns pointer constraint)

func SliceTyped added in v0.3.0

func SliceTyped[T any, R any](elementSchema any, paramArgs ...any) *ZodSlice[T, R]

SliceTyped creates slice schema with explicit constraint type (universal constructor)

func (*ZodSlice[T, R]) And added in v0.5.4

func (z *ZodSlice[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.Slice[string](gozod.String()).Min(1).And(gozod.Slice[string](gozod.String()).Max(10))
result, _ := schema.Parse([]string{"a", "b"}) // Must satisfy both constraints

func (*ZodSlice[T, R]) Check

func (z *ZodSlice[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSlice[T, R]

Check adds a custom validation function for slice schema that can push multiple issues.

func (*ZodSlice[T, R]) CloneFrom

func (z *ZodSlice[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodSlice[T, R]) Default

func (z *ZodSlice[T, R]) Default(v []T) *ZodSlice[T, R]

Default preserves current constraint type

func (*ZodSlice[T, R]) DefaultFunc

func (z *ZodSlice[T, R]) DefaultFunc(fn func() []T) *ZodSlice[T, R]

DefaultFunc preserves current constraint type

func (*ZodSlice[T, R]) Describe added in v0.5.4

func (z *ZodSlice[T, R]) Describe(description string) *ZodSlice[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodSlice[T, R]) Element

func (z *ZodSlice[T, R]) Element() any

Element returns the element schema for this slice

func (*ZodSlice[T, R]) GetInternals

func (z *ZodSlice[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodSlice[T, R]) IsNilable added in v0.3.0

func (z *ZodSlice[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodSlice[T, R]) IsOptional added in v0.3.0

func (z *ZodSlice[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodSlice[T, R]) Length

func (z *ZodSlice[T, R]) Length(exactLen int, params ...any) *ZodSlice[T, R]

Length sets exact number of elements

func (*ZodSlice[T, R]) Max

func (z *ZodSlice[T, R]) Max(maxLen int, params ...any) *ZodSlice[T, R]

Max sets maximum number of elements

func (*ZodSlice[T, R]) Meta added in v0.3.1

func (z *ZodSlice[T, R]) Meta(meta core.GlobalMeta) *ZodSlice[T, R]

Meta stores metadata for this slice schema in the global registry.

func (*ZodSlice[T, R]) Min

func (z *ZodSlice[T, R]) Min(minLen int, params ...any) *ZodSlice[T, R]

Min sets minimum number of elements

func (*ZodSlice[T, R]) MustParse

func (z *ZodSlice[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodSlice[T, R]) MustStrictParse added in v0.4.0

func (z *ZodSlice[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodSlice[T, R]) Nilable

func (z *ZodSlice[T, R]) Nilable() *ZodSlice[T, *[]T]

Nilable allows nil values (always returns pointer constraint)

func (*ZodSlice[T, R]) NonEmpty

func (z *ZodSlice[T, R]) NonEmpty(params ...any) *ZodSlice[T, R]

NonEmpty ensures slice has at least one element

func (*ZodSlice[T, R]) NonOptional added in v0.3.0

func (z *ZodSlice[T, R]) NonOptional() *ZodSlice[T, []T]

NonOptional removes Optional flag and enforces non-nil slice constraint ([]T).

func (*ZodSlice[T, R]) Nullish

func (z *ZodSlice[T, R]) Nullish() *ZodSlice[T, *[]T]

Nullish combines optional and nilable modifiers (always returns pointer constraint)

func (*ZodSlice[T, R]) Optional

func (z *ZodSlice[T, R]) Optional() *ZodSlice[T, *[]T]

Optional creates optional slice schema (always returns pointer constraint)

func (*ZodSlice[T, R]) Or added in v0.5.4

func (z *ZodSlice[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.Slice[string](gozod.String()).Or(gozod.Slice[int](gozod.Int()))

func (*ZodSlice[T, R]) Overwrite added in v0.3.0

func (z *ZodSlice[T, R]) Overwrite(transform func(R) R, params ...any) *ZodSlice[T, R]

Overwrite transforms slice value while keeping the same type

func (*ZodSlice[T, R]) Parse

func (z *ZodSlice[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using slice-specific parsing logic with type safety

func (*ZodSlice[T, R]) ParseAny added in v0.3.0

func (z *ZodSlice[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodSlice[T, R]) Pipe

func (z *ZodSlice[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using the WrapFn pattern. Instead of using adapter structures, this creates a target function that handles type conversion.

func (*ZodSlice[T, R]) Prefault

func (z *ZodSlice[T, R]) Prefault(v []T) *ZodSlice[T, R]

Prefault provides fallback values on validation failure (preserves constraint type)

func (*ZodSlice[T, R]) PrefaultFunc

func (z *ZodSlice[T, R]) PrefaultFunc(fn func() []T) *ZodSlice[T, R]

PrefaultFunc provides dynamic fallback values (preserves constraint type)

func (*ZodSlice[T, R]) Refine

func (z *ZodSlice[T, R]) Refine(fn func(R) bool, params ...any) *ZodSlice[T, R]

Refine adds type-safe custom validation with automatic constraint type matching

func (*ZodSlice[T, R]) RefineAny

func (z *ZodSlice[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodSlice[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodSlice[T, R]) StrictParse added in v0.4.0

func (z *ZodSlice[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodSlice[T, R]) Transform

func (z *ZodSlice[T, R]) Transform(fn func(R, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform applies a transformation function using the WrapFn pattern. Slice types pass the constraint type R directly to transformation functions.

func (*ZodSlice[T, R]) With added in v0.5.4

func (z *ZodSlice[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSlice[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodSliceDef

type ZodSliceDef struct {
	core.ZodTypeDef
	Element any // The element schema (type-erased for flexibility)
}

ZodSliceDef defines the schema definition for slice validation

type ZodSliceInternals

type ZodSliceInternals[T any] struct {
	core.ZodTypeInternals
	Def     *ZodSliceDef // Schema definition reference
	Element any          // Element schema for runtime validation
}

ZodSliceInternals contains the internal state for slice schema

type ZodString

type ZodString[T StringConstraint] struct {
	// contains filtered or unexported fields
}

ZodString represents a string validation schema with type safety

func CoercedString added in v0.2.1

func CoercedString(params ...any) *ZodString[string]

CoercedString creates a new string schema with coercion enabled

func CoercedStringPtr added in v0.3.0

func CoercedStringPtr(params ...any) *ZodString[*string]

CoercedStringPtr creates a new string schema with pointer type and coercion enabled

func String

func String(params ...any) *ZodString[string]

String creates a new string schema

func StringPtr added in v0.3.0

func StringPtr(params ...any) *ZodString[*string]

StringPtr creates a new string schema with pointer type

func StringTyped added in v0.3.0

func StringTyped[T StringConstraint](params ...any) *ZodString[T]

StringTyped creates a new string schema with specific type

func (*ZodString[T]) And added in v0.5.4

func (z *ZodString[T]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.String().Min(3).And(gozod.String().Max(10))
result, _ := schema.Parse("hello") // Must satisfy both constraints

func (*ZodString[T]) Check added in v0.3.0

func (z *ZodString[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodString[T]

Check adds a custom validation function that can push multiple issues via ParsePayload.

func (*ZodString[T]) CloneFrom

func (z *ZodString[T]) CloneFrom(source any)

CloneFrom copies the internal state from another schema

func (*ZodString[T]) Coerce

func (z *ZodString[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for string type conversion

func (*ZodString[T]) Default

func (z *ZodString[T]) Default(v string) *ZodString[T]

Default keeps the current generic type T.

func (*ZodString[T]) DefaultFunc

func (z *ZodString[T]) DefaultFunc(fn func() string) *ZodString[T]

DefaultFunc keeps the current generic type T.

func (*ZodString[T]) Describe added in v0.5.3

func (z *ZodString[T]) Describe(description string) *ZodString[T]

Describe adds a description to the schema. This description is stored in the GlobalRegistry and can be used for documentation or JSON Schema generation.

Example:

schema := gozod.String().Describe("User's email address")

func (*ZodString[T]) Email

func (z *ZodString[T]) Email(params ...any) *ZodString[T]

Email adds email format validation

func (*ZodString[T]) EndsWith

func (z *ZodString[T]) EndsWith(suffix string, params ...any) *ZodString[T]

EndsWith adds suffix validation

func (*ZodString[T]) ExactOptional added in v0.5.4

func (z *ZodString[T]) ExactOptional() *ZodString[T]

ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional(), which accepts both absent keys AND nil values, ExactOptional() only accepts absent keys in object fields. The output type remains the same as the input type (no | undefined).

func (*ZodString[T]) GetInternals

func (z *ZodString[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodString[T]) Includes

func (z *ZodString[T]) Includes(substring string, params ...any) *ZodString[T]

Includes adds substring validation

func (*ZodString[T]) IsNilable added in v0.3.0

func (z *ZodString[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodString[T]) IsOptional added in v0.3.0

func (z *ZodString[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodString[T]) JSON

func (z *ZodString[T]) JSON(params ...any) *ZodString[T]

JSON adds JSON format validation

func (*ZodString[T]) JWT

func (z *ZodString[T]) JWT(params ...any) *ZodString[T]

JWT adds JWT token format validation. Supports validating the JWT structure and optionally checking the "alg" header.

Usage forms:

JWT() - validates standard JWT format
JWT("HS256") - validates format and requires "alg": "HS256" header
JWT(validate.JWTOptions{Algorithm: "RS256"}) - full options
JWT("invalid token") - custom error message

func (*ZodString[T]) Length

func (z *ZodString[T]) Length(length int, params ...any) *ZodString[T]

Length adds exact length validation

func (*ZodString[T]) Lowercase added in v0.5.5

func (z *ZodString[T]) Lowercase(params ...any) *ZodString[T]

Lowercase validates that the string contains no uppercase letters. TypeScript Zod v4 equivalent: z.string().lowercase() Matches Zod v4's regex: /^[^A-Z]*$/ Empty strings pass validation (consistent with Zod v4).

func (*ZodString[T]) MAC added in v0.5.3

func (z *ZodString[T]) MAC(params ...any) *ZodString[T]

MAC adds MAC address format validation with flexible parameter support. Aligns with Zod TypeScript implementation using case-sensitive matching.

Usage forms:

MAC() - uses default colon delimiter ":"
MAC("-") - uses specified delimiter
MAC(validate.MACOptions{Delimiter: "."}) - full options
MAC("invalid MAC address") - custom error message

Examples:

z.String().MAC().Parse("00:1A:2B:3C:4D:5E") // valid with default ":"
z.String().MAC("-").Parse("00-1a-2b-3c-4d-5e") // valid with "-"
z.String().MAC(".").Parse("00.1A.2B.3C.4D.5E") // valid with "."

func (*ZodString[T]) Max

func (z *ZodString[T]) Max(maxLen int, params ...any) *ZodString[T]

Max adds maximum length validation

func (*ZodString[T]) Meta added in v0.3.1

func (z *ZodString[T]) Meta(meta core.GlobalMeta) *ZodString[T]

Meta stores metadata for this schema in the global registry. This does not clone internals because metadata does not affect validation.

func (*ZodString[T]) Min

func (z *ZodString[T]) Min(minLen int, params ...any) *ZodString[T]

Min adds minimum length validation

func (*ZodString[T]) MustParse

func (z *ZodString[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error.

func (*ZodString[T]) MustParseAny added in v0.3.1

func (z *ZodString[T]) MustParseAny(input any, ctx ...*core.ParseContext) any

MustParseAny validates the input value and panics on failure

func (*ZodString[T]) MustStrictParse added in v0.4.0

func (z *ZodString[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodString[T]) Nilable

func (z *ZodString[T]) Nilable() *ZodString[*string]

Nilable always returns *string because the value may be nil.

func (*ZodString[T]) NonOptional added in v0.3.0

func (z *ZodString[T]) NonOptional() *ZodString[string]

NonOptional removes the optional flag and returns a new schema with string value type

func (*ZodString[T]) Normalize added in v0.5.5

func (z *ZodString[T]) Normalize(form ...string) *ZodString[T]

Normalize transforms the string using Unicode normalization. TypeScript Zod v4 equivalent: z.string().normalize(form?) Supported normalization forms:

  • "NFC" - Canonical Decomposition, followed by Canonical Composition (default)
  • "NFD" - Canonical Decomposition
  • "NFKC" - Compatibility Decomposition, followed by Canonical Composition
  • "NFKD" - Compatibility Decomposition

Example:

z.String().Normalize().Parse("café")      // Uses NFC by default
z.String().Normalize("NFD").Parse("café") // Uses NFD

func (*ZodString[T]) Nullish

func (z *ZodString[T]) Nullish() *ZodString[*string]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodString[T]) Optional

func (z *ZodString[T]) Optional() *ZodString[*string]

Optional always returns *string because the optional value may be nil.

func (*ZodString[T]) Or added in v0.5.4

func (z *ZodString[T]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.String().Or(gozod.Int())
result, _ := schema.Parse("hello") // Accepts string
result, _ = schema.Parse(42)       // Accepts int

func (*ZodString[T]) Overwrite added in v0.3.0

func (z *ZodString[T]) Overwrite(transform func(T) T, params ...any) *ZodString[T]

Overwrite applies a transformation function that must return the same type T

func (*ZodString[T]) Parse

func (z *ZodString[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety.

func (*ZodString[T]) ParseAny added in v0.3.0

func (z *ZodString[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodString[T]) Pipe

func (z *ZodString[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline with another schema

func (*ZodString[T]) Prefault

func (z *ZodString[T]) Prefault(v string) *ZodString[T]

Prefault keeps the current generic type T.

func (*ZodString[T]) PrefaultFunc

func (z *ZodString[T]) PrefaultFunc(fn func() string) *ZodString[T]

PrefaultFunc keeps the current generic type T.

func (*ZodString[T]) Refine

func (z *ZodString[T]) Refine(fn func(T) bool, params ...any) *ZodString[T]

Refine applies a custom validation function that matches the schema's output type T.

func (*ZodString[T]) RefineAny

func (z *ZodString[T]) RefineAny(fn func(any) bool, params ...any) *ZodString[T]

RefineAny adds flexible custom validation logic

func (*ZodString[T]) Regex

func (z *ZodString[T]) Regex(pattern *regexp.Regexp, params ...any) *ZodString[T]

Regex adds custom regex validation

func (*ZodString[T]) RegexString added in v0.3.0

func (z *ZodString[T]) RegexString(pattern string, params ...any) *ZodString[T]

RegexString adds custom regex validation using string pattern (convenience method)

func (*ZodString[T]) Slugify added in v0.5.3

func (z *ZodString[T]) Slugify(params ...any) *ZodString[T]

Slugify transforms the string to a URL-friendly slug. Matches Zod v4's z.string().slugify() implementation: 1. Lowercase the string 2. Trim whitespace 3. Remove non-word/non-space/non-hyphen characters 4. Replace spaces and underscores with hyphens 5. Trim leading/trailing hyphens

Example:

z.String().Slugify().Parse("Hello World")      // -> "hello-world"
z.String().Slugify().Parse("  Hello   World  ") // -> "hello-world"
z.String().Slugify().Parse("Hello@World#123")  // -> "helloworld123"

func (*ZodString[T]) StartsWith

func (z *ZodString[T]) StartsWith(prefix string, params ...any) *ZodString[T]

StartsWith adds prefix validation

func (*ZodString[T]) StrictParse added in v0.4.0

func (z *ZodString[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodString[T]) ToLowerCase

func (z *ZodString[T]) ToLowerCase(params ...any) *ZodString[T]

ToLowerCase transforms the string to lower case

func (*ZodString[T]) ToUpperCase

func (z *ZodString[T]) ToUpperCase(params ...any) *ZodString[T]

ToUpperCase transforms the string to upper case

func (*ZodString[T]) Transform

func (z *ZodString[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform applies a transformation function to the validated string

func (*ZodString[T]) Trim

func (z *ZodString[T]) Trim(params ...any) *ZodString[T]

Trim adds string trimming transformation

func (*ZodString[T]) Uppercase added in v0.5.5

func (z *ZodString[T]) Uppercase(params ...any) *ZodString[T]

Uppercase validates that the string contains no lowercase letters. TypeScript Zod v4 equivalent: z.string().uppercase() Matches Zod v4's regex: /^[^a-z]*$/ Empty strings pass validation (consistent with Zod v4).

func (*ZodString[T]) With added in v0.5.4

func (z *ZodString[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodString[T]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

This method exists for TypeScript Zod v4 API compatibility, where .with() is simply an alias for .check().

type ZodStringBool

type ZodStringBool[T StringBoolConstraint] struct {
	// contains filtered or unexported fields
}

ZodStringBool represents a string-to-boolean validation schema with type safety

func CoercedStringBool added in v0.3.0

func CoercedStringBool(params ...any) *ZodStringBool[bool]

CoercedStringBool creates a coerced stringbool schema

func CoercedStringBoolPtr added in v0.3.0

func CoercedStringBoolPtr(params ...any) *ZodStringBool[*bool]

CoercedStringBoolPtr creates a coerced stringbool schema for *bool

func StringBool

func StringBool(params ...any) *ZodStringBool[bool]

StringBool creates bool schema with type-inference support

func StringBoolPtr added in v0.3.0

func StringBoolPtr(params ...any) *ZodStringBool[*bool]

StringBoolPtr creates schema for *bool

func StringBoolTyped added in v0.3.0

func StringBoolTyped[T StringBoolConstraint](params ...any) *ZodStringBool[T]

StringBoolTyped is the generic constructor for stringbool schemas

func (*ZodStringBool[T]) CloneFrom added in v0.3.0

func (z *ZodStringBool[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodStringBool[T]) Coerce

func (z *ZodStringBool[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for string-to-bool type conversion

func (*ZodStringBool[T]) Default

func (z *ZodStringBool[T]) Default(v bool) *ZodStringBool[T]

Default preserves current generic type T

func (*ZodStringBool[T]) DefaultFunc

func (z *ZodStringBool[T]) DefaultFunc(fn func() bool) *ZodStringBool[T]

DefaultFunc preserves current generic type T

func (*ZodStringBool[T]) Describe added in v0.5.4

func (z *ZodStringBool[T]) Describe(description string) *ZodStringBool[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodStringBool[T]) GetInternals

func (z *ZodStringBool[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodStringBool[T]) IsNilable added in v0.3.0

func (z *ZodStringBool[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodStringBool[T]) IsOptional added in v0.3.0

func (z *ZodStringBool[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodStringBool[T]) Meta added in v0.3.1

func (z *ZodStringBool[T]) Meta(meta core.GlobalMeta) *ZodStringBool[T]

Meta stores metadata for this stringbool schema.

func (*ZodStringBool[T]) MustParse

func (z *ZodStringBool[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error.

func (*ZodStringBool[T]) MustStrictParse added in v0.4.0

func (z *ZodStringBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodStringBool[T]) Nilable

func (z *ZodStringBool[T]) Nilable() *ZodStringBool[*bool]

Nilable allows nil values, returns pointer type

func (*ZodStringBool[T]) Nullish

func (z *ZodStringBool[T]) Nullish() *ZodStringBool[*bool]

Nullish combines optional and nilable modifiers

func (*ZodStringBool[T]) Optional

func (z *ZodStringBool[T]) Optional() *ZodStringBool[*bool]

Optional always returns *bool for nullable semantics

func (*ZodStringBool[T]) Overwrite added in v0.3.0

func (z *ZodStringBool[T]) Overwrite(transform func(T) T, params ...any) *ZodStringBool[T]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodStringBool[T]) Parse

func (z *ZodStringBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety.

func (*ZodStringBool[T]) ParseAny added in v0.3.0

func (z *ZodStringBool[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodStringBool[T]) Pipe

func (z *ZodStringBool[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodStringBool[T]) Prefault

func (z *ZodStringBool[T]) Prefault(v string) *ZodStringBool[T]

Prefault provides fallback values on validation failure According to Zod v4 semantics, prefault accepts input type (string) for StringBool

func (*ZodStringBool[T]) PrefaultFunc

func (z *ZodStringBool[T]) PrefaultFunc(fn func() string) *ZodStringBool[T]

PrefaultFunc keeps current generic type T. According to Zod v4 semantics, prefault function returns input type (string) for StringBool

func (*ZodStringBool[T]) Refine

func (z *ZodStringBool[T]) Refine(fn func(T) bool, params ...any) *ZodStringBool[T]

Refine adds type-safe custom validation logic to the stringbool schema

func (*ZodStringBool[T]) RefineAny

func (z *ZodStringBool[T]) RefineAny(fn func(any) bool, params ...any) *ZodStringBool[T]

RefineAny provides flexible validation without type conversion

func (*ZodStringBool[T]) StrictParse added in v0.4.0

func (z *ZodStringBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodStringBool[T]) Transform

func (z *ZodStringBool[T]) Transform(fn func(bool, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using WrapFn pattern

type ZodStringBoolDef

type ZodStringBoolDef struct {
	core.ZodTypeDef
	Truthy        []string // Truthy string values
	Falsy         []string // Falsy string values
	Case          string   // "sensitive" or "insensitive"
	CustomOptions bool     // Whether custom options were provided
}

ZodStringBoolDef defines the configuration for string boolean validation

type ZodStringBoolInternals

type ZodStringBoolInternals struct {
	core.ZodTypeInternals
	Def    *ZodStringBoolDef   // Schema definition
	Truthy map[string]struct{} // Truthy values set for fast lookup
	Falsy  map[string]struct{} // Falsy values set for fast lookup
}

ZodStringBoolInternals contains stringbool validator internal state

type ZodStringDef

type ZodStringDef struct {
	core.ZodTypeDef
}

ZodStringDef defines the configuration for string validation

type ZodStringInternals

type ZodStringInternals struct {
	core.ZodTypeInternals
	Def *ZodStringDef // Schema definition
}

ZodStringInternals contains string validator internal state

type ZodStruct

type ZodStruct[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodStruct represents a type-safe struct validation schema with dual generic parameters T is the base comparable type, R is the constraint type (T | *T)

func FromStruct added in v0.5.0

func FromStruct[T any]() *ZodStruct[T, T]

FromStruct creates a ZodStruct schema from struct tags This is a convenience function that uses the tag parsing infrastructure

func FromStructPtr added in v0.5.0

func FromStructPtr[T any]() *ZodStruct[T, *T]

FromStructPtr creates a ZodStruct schema for pointer types from struct tags

func Struct

func Struct[T any](params ...any) *ZodStruct[T, T]

Struct creates a struct schema for validating Go struct instances directly Usage: Struct[User]() validates User struct instances Usage: Struct[User](core.StructSchema{...}) validates User with field schemas

func StructPtr added in v0.3.0

func StructPtr[T any](params ...any) *ZodStruct[T, *T]

StructPtr creates a struct schema for validating pointer to Go struct instances Usage: StructPtr[User]() validates *User (can be nil) Usage: StructPtr[User](core.StructSchema{...}) validates *User with field schemas

func (*ZodStruct[T, R]) Check added in v0.3.0

func (z *ZodStruct[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodStruct[T, R]

Check adds a custom validation function that can report multiple issues for struct schema.

func (*ZodStruct[T, R]) CloneFrom

func (z *ZodStruct[T, R]) CloneFrom(source any)

CloneFrom allows copying configuration from a source

func (*ZodStruct[T, R]) Default

func (z *ZodStruct[T, R]) Default(v T) *ZodStruct[T, R]

Default keeps the current generic constraint type R.

func (*ZodStruct[T, R]) DefaultFunc

func (z *ZodStruct[T, R]) DefaultFunc(fn func() T) *ZodStruct[T, R]

DefaultFunc keeps the current generic constraint type R.

func (*ZodStruct[T, R]) Describe added in v0.5.4

func (z *ZodStruct[T, R]) Describe(description string) *ZodStruct[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodStruct[T, R]) Extend

func (z *ZodStruct[T, R]) Extend(augmentation core.StructSchema, params ...any) *ZodStruct[T, R]

Extend creates a new struct by extending with additional field schemas

func (*ZodStruct[T, R]) GetCatchall added in v0.3.1

func (z *ZodStruct[T, R]) GetCatchall() core.ZodSchema

GetCatchall returns nil since structs don't support catchall by default

func (*ZodStruct[T, R]) GetInternals

func (z *ZodStruct[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodStruct[T, R]) GetUnknownKeys added in v0.3.1

func (z *ZodStruct[T, R]) GetUnknownKeys() string

GetUnknownKeys returns the unknown keys handling mode for JSON Schema conversion Structs are strict by default (don't allow additional properties)

func (*ZodStruct[T, R]) IsNilable added in v0.3.0

func (z *ZodStruct[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodStruct[T, R]) IsOptional added in v0.3.0

func (z *ZodStruct[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodStruct[T, R]) Meta added in v0.3.1

func (z *ZodStruct[T, R]) Meta(meta core.GlobalMeta) *ZodStruct[T, R]

Meta stores metadata for this struct schema.

func (*ZodStruct[T, R]) MustParse

func (z *ZodStruct[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodStruct[T, R]) MustStrictParse added in v0.4.0

func (z *ZodStruct[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodStruct[T, R]) Nilable

func (z *ZodStruct[T, R]) Nilable() *ZodStruct[T, *T]

Nilable always returns *T constraint because the value may be nil.

func (*ZodStruct[T, R]) NonOptional added in v0.3.0

func (z *ZodStruct[T, R]) NonOptional() *ZodStruct[T, T]

NonOptional removes Optional flag and enforces non-nil struct value (T).

func (*ZodStruct[T, R]) Nullish

func (z *ZodStruct[T, R]) Nullish() *ZodStruct[T, *T]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodStruct[T, R]) Optional

func (z *ZodStruct[T, R]) Optional() *ZodStruct[T, *T]

Optional always returns *T constraint because the optional value may be nil.

func (*ZodStruct[T, R]) Overwrite added in v0.3.0

func (z *ZodStruct[T, R]) Overwrite(transform func(R) R, params ...any) *ZodStruct[T, R]

Overwrite transforms the input value while preserving the original type. Unlike Transform, this method doesn't change the inferred type and returns an instance of the original class. The transformation function is stored as a check, so it doesn't modify the inferred type.

func (*ZodStruct[T, R]) Parse

func (z *ZodStruct[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using struct-specific parsing logic with engine.ParseComplex

func (*ZodStruct[T, R]) ParseAny added in v0.3.0

func (z *ZodStruct[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodStruct[T, R]) Partial

func (z *ZodStruct[T, R]) Partial(keys ...[]string) *ZodStruct[T, R]

Partial makes all fields optional by allowing zero values

func (*ZodStruct[T, R]) Pipe

func (z *ZodStruct[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodStruct[T, R]) Prefault

func (z *ZodStruct[T, R]) Prefault(v T) *ZodStruct[T, R]

Prefault provides fallback values on validation failure

func (*ZodStruct[T, R]) PrefaultFunc

func (z *ZodStruct[T, R]) PrefaultFunc(fn func() T) *ZodStruct[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodStruct[T, R]) Refine

func (z *ZodStruct[T, R]) Refine(fn func(R) bool, params ...any) *ZodStruct[T, R]

func (*ZodStruct[T, R]) RefineAny

func (z *ZodStruct[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodStruct[T, R]

func (*ZodStruct[T, R]) Required added in v0.4.0

func (z *ZodStruct[T, R]) Required(fields ...[]string) *ZodStruct[T, R]

Required makes all fields required (opposite of Partial)

func (*ZodStruct[T, R]) Shape

func (z *ZodStruct[T, R]) Shape() core.StructSchema

Shape returns the struct field schemas for JSON Schema conversion

func (*ZodStruct[T, R]) StrictParse added in v0.4.0

func (z *ZodStruct[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodStruct[T, R]) Transform added in v0.3.0

func (z *ZodStruct[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates a type-safe transformation using WrapFn pattern

func (*ZodStruct[T, R]) With added in v0.5.4

func (z *ZodStruct[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodStruct[T, R]

With is an alias for Check - adds a custom validation function. TypeScript Zod v4 equivalent: schema.with(...)

type ZodStructDef

type ZodStructDef struct {
	core.ZodTypeDef
	Shape core.StructSchema // Field schemas for struct validation
}

ZodStructDef defines the schema definition for struct validation

type ZodStructInternals

type ZodStructInternals struct {
	core.ZodTypeInternals
	Def               *ZodStructDef     // Schema definition reference
	Shape             core.StructSchema // Field schemas for runtime validation
	IsPartial         bool              // Whether this is a partial struct (fields can be zero values)
	PartialExceptions map[string]bool   // Fields that should remain required in partial mode
}

ZodStructInternals contains the internal state for struct schema

type ZodTime added in v0.3.0

type ZodTime[T TimeConstraint] struct {
	// contains filtered or unexported fields
}

ZodTime represents a time validation schema with type safety

func CoercedTime added in v0.3.0

func CoercedTime(args ...any) *ZodTime[time.Time]

CoercedTime creates a time.Time schema with coercion enabled

func CoercedTimePtr added in v0.3.0

func CoercedTimePtr(args ...any) *ZodTime[*time.Time]

CoercedTimePtr creates a *time.Time schema with coercion enabled

func Time added in v0.3.0

func Time(params ...any) *ZodTime[time.Time]

Time creates a time.Time schema following Zod TypeScript v4 pattern Usage:

Time()                    // no parameters
Time("custom error")      // string shorthand
Time(SchemaParams{...})   // full parameters

func TimePtr added in v0.3.0

func TimePtr(params ...any) *ZodTime[*time.Time]

TimePtr creates a schema for *time.Time

func TimeTyped added in v0.3.0

func TimeTyped[T TimeConstraint](params ...any) *ZodTime[T]

TimeTyped is the underlying generic function for creating time schemas allowing for explicit type parameterization

func (*ZodTime[T]) CloneFrom added in v0.3.0

func (z *ZodTime[T]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodTime[T]) Coerce added in v0.3.0

func (z *ZodTime[T]) Coerce(input any) (any, bool)

Coerce implements Coercible interface for time type conversion

func (*ZodTime[T]) Default added in v0.3.0

func (z *ZodTime[T]) Default(v time.Time) *ZodTime[T]

Default keeps the current generic type T.

func (*ZodTime[T]) DefaultFunc added in v0.3.0

func (z *ZodTime[T]) DefaultFunc(fn func() time.Time) *ZodTime[T]

DefaultFunc keeps the current generic type T.

func (*ZodTime[T]) Describe added in v0.5.4

func (z *ZodTime[T]) Describe(description string) *ZodTime[T]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodTime[T]) GetInternals added in v0.3.0

func (z *ZodTime[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodTime[T]) IsNilable added in v0.3.0

func (z *ZodTime[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodTime[T]) IsOptional added in v0.3.0

func (z *ZodTime[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodTime[T]) Meta added in v0.3.1

func (z *ZodTime[T]) Meta(meta core.GlobalMeta) *ZodTime[T]

Meta stores metadata for this time schema.

func (*ZodTime[T]) MustParse added in v0.3.0

func (z *ZodTime[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the type-safe variant that panics on error.

func (*ZodTime[T]) MustStrictParse added in v0.4.0

func (z *ZodTime[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodTime[T]) Nilable added in v0.3.0

func (z *ZodTime[T]) Nilable() *ZodTime[*time.Time]

Nilable always returns *time.Time because the value may be nil.

func (*ZodTime[T]) Nullish added in v0.3.0

func (z *ZodTime[T]) Nullish() *ZodTime[*time.Time]

Nullish combines optional and nilable modifiers for maximum flexibility

func (*ZodTime[T]) Optional added in v0.3.0

func (z *ZodTime[T]) Optional() *ZodTime[*time.Time]

Optional always returns *time.Time because the optional value may be nil.

func (*ZodTime[T]) Overwrite added in v0.3.0

func (z *ZodTime[T]) Overwrite(transform func(T) T, params ...any) *ZodTime[T]

Overwrite transforms time value while keeping the same type

func (*ZodTime[T]) Parse added in v0.3.0

func (z *ZodTime[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns a value that matches the generic type T with full type safety.

func (*ZodTime[T]) ParseAny added in v0.3.0

func (z *ZodTime[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodTime[T]) Pipe added in v0.3.0

func (z *ZodTime[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]

Pipe creates a pipeline using WrapFn pattern

func (*ZodTime[T]) Prefault added in v0.3.0

func (z *ZodTime[T]) Prefault(v time.Time) *ZodTime[T]

Prefault keeps the current generic type T.

func (*ZodTime[T]) PrefaultFunc added in v0.3.0

func (z *ZodTime[T]) PrefaultFunc(fn func() time.Time) *ZodTime[T]

PrefaultFunc keeps the current generic type T.

func (*ZodTime[T]) Refine added in v0.3.0

func (z *ZodTime[T]) Refine(fn func(T) bool, params ...any) *ZodTime[T]

Refine applies a custom validation function that matches the schema's output type T. The callback will be executed even when the value is nil (for *time.Time schemas) to align with Zod v4 semantics.

func (*ZodTime[T]) RefineAny added in v0.3.0

func (z *ZodTime[T]) RefineAny(fn func(any) bool, params ...any) *ZodTime[T]

RefineAny adds flexible custom validation logic

func (*ZodTime[T]) StrictParse added in v0.4.0

func (z *ZodTime[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodTime[T]) Transform added in v0.3.0

func (z *ZodTime[T]) Transform(fn func(time.Time, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]

Transform creates a type-safe transformation using WrapFn pattern

type ZodTimeDef added in v0.3.0

type ZodTimeDef struct {
	core.ZodTypeDef
}

ZodTimeDef defines the configuration for time validation

type ZodTimeInternals added in v0.3.0

type ZodTimeInternals struct {
	core.ZodTypeInternals
	Def *ZodTimeDef // Schema definition
}

ZodTimeInternals contains time validator internal state

type ZodTransform

type ZodTransform[In any, Out any] struct {
	// contains filtered or unexported fields
}

ZodTransform represents a schema with a custom transformation.

func (*ZodTransform[In, Out]) GetInner added in v0.3.1

func (z *ZodTransform[In, Out]) GetInner() core.ZodSchema

GetInner returns the input schema for the transformation.

func (*ZodTransform[In, Out]) GetInternals

func (z *ZodTransform[In, Out]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the ZodTransform schema.

func (*ZodTransform[In, Out]) MustStrictParse added in v0.4.0

func (z *ZodTransform[In, Out]) MustStrictParse(input Out, ctx ...*core.ParseContext) Out

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodTransform[In, Out]) Parse

func (z *ZodTransform[In, Out]) Parse(input any) (any, error)

Parse applies the transformation to the input value.

func (*ZodTransform[In, Out]) StrictParse added in v0.4.0

func (z *ZodTransform[In, Out]) StrictParse(input Out, ctx ...*core.ParseContext) (Out, error)

StrictParse validates the input using strict parsing rules and returns the transformed result

func (*ZodTransform[In, Out]) Type added in v0.3.0

func (z *ZodTransform[In, Out]) Type() core.ZodTypeCode

Type returns the type of the schema

type ZodTransformDef

type ZodTransformDef struct {
	core.ZodTypeDef
	// contains filtered or unexported fields
}

ZodTransformDef represents the definition of a transformation schema.

func (*ZodTransformDef) Transform added in v0.3.1

func (d *ZodTransformDef) Transform() func(any, *core.RefinementContext) (any, error)

type ZodTransformInternals

type ZodTransformInternals struct {
	core.ZodTypeInternals
	Def *ZodTransformDef
}

ZodTransformInternals contains internal state for ZodTransform.

type ZodTuple added in v0.5.4

type ZodTuple[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodTuple represents a type-safe tuple validation schema TypeScript Zod v4 equivalent: z.tuple([...]) T: base type ([]any), R: constraint type ([]any or *[]any)

func Tuple added in v0.5.4

func Tuple(items ...core.ZodSchema) *ZodTuple[[]any, []any]

Tuple creates a tuple schema with fixed positional items TypeScript Zod v4 equivalent: z.tuple([...])

Usage:

tuple := gozod.Tuple(gozod.String(), gozod.Int())
result, err := tuple.Parse([]any{"hello", 42})

func TuplePtr added in v0.5.4

func TuplePtr(items ...core.ZodSchema) *ZodTuple[[]any, *[]any]

TuplePtr creates an optional tuple schema that returns *[]any

func TupleTyped added in v0.5.4

func TupleTyped[T any, R any](items []core.ZodSchema, rest core.ZodSchema, params ...any) *ZodTuple[T, R]

TupleTyped creates a tuple schema with explicit type parameters

func TupleWithRest added in v0.5.4

func TupleWithRest(items []core.ZodSchema, rest core.ZodSchema, params ...any) *ZodTuple[[]any, []any]

TupleWithRest creates a tuple schema with fixed items and a rest element TypeScript Zod v4 equivalent: z.tuple([...]).rest(schema)

Usage:

tuple := gozod.TupleWithRest([]core.ZodSchema{gozod.String(), gozod.Int()}, gozod.Bool())
result, err := tuple.Parse([]any{"hello", 42, true, false})

func (*ZodTuple[T, R]) Check added in v0.5.4

func (z *ZodTuple[T, R]) Check(check core.ZodCheck) *ZodTuple[T, R]

Check adds a custom validation check with payload access

func (*ZodTuple[T, R]) Default added in v0.5.4

func (z *ZodTuple[T, R]) Default(v []any) *ZodTuple[T, R]

Default sets a default value for nil input

func (*ZodTuple[T, R]) Describe added in v0.5.4

func (z *ZodTuple[T, R]) Describe(description string) *ZodTuple[T, R]

Describe registers a description in the global registry TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodTuple[T, R]) GetInternals added in v0.5.4

func (z *ZodTuple[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodTuple[T, R]) GetItems added in v0.5.4

func (z *ZodTuple[T, R]) GetItems() []core.ZodSchema

GetItems returns the tuple item schemas

func (*ZodTuple[T, R]) GetRest added in v0.5.4

func (z *ZodTuple[T, R]) GetRest() core.ZodSchema

GetRest returns the rest element schema

func (*ZodTuple[T, R]) IsNilable added in v0.5.4

func (z *ZodTuple[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodTuple[T, R]) IsOptional added in v0.5.4

func (z *ZodTuple[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodTuple[T, R]) Length added in v0.5.4

func (z *ZodTuple[T, R]) Length(length int, params ...any) *ZodTuple[T, R]

Length sets exact tuple length validation

func (*ZodTuple[T, R]) Max added in v0.5.4

func (z *ZodTuple[T, R]) Max(maximum int, params ...any) *ZodTuple[T, R]

Max sets maximum tuple length validation

func (*ZodTuple[T, R]) Meta added in v0.5.4

func (z *ZodTuple[T, R]) Meta(meta core.GlobalMeta) *ZodTuple[T, R]

Meta stores metadata for this tuple schema

func (*ZodTuple[T, R]) Min added in v0.5.4

func (z *ZodTuple[T, R]) Min(minimum int, params ...any) *ZodTuple[T, R]

Min sets minimum tuple length validation

func (*ZodTuple[T, R]) MustParse added in v0.5.4

func (z *ZodTuple[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodTuple[T, R]) MustStrictParse added in v0.5.4

func (z *ZodTuple[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure. This method provides zero-overhead abstraction with strict type constraints.

func (*ZodTuple[T, R]) Nilable added in v0.5.4

func (z *ZodTuple[T, R]) Nilable() *ZodTuple[T, *[]any]

Nilable marks this tuple as nilable

func (*ZodTuple[T, R]) NonEmpty added in v0.5.4

func (z *ZodTuple[T, R]) NonEmpty(params ...any) *ZodTuple[T, R]

NonEmpty ensures tuple has at least one element

func (*ZodTuple[T, R]) Nullish added in v0.5.4

func (z *ZodTuple[T, R]) Nullish() *ZodTuple[T, *[]any]

Nullish marks this tuple as nullish (optional + nilable)

func (*ZodTuple[T, R]) Optional added in v0.5.4

func (z *ZodTuple[T, R]) Optional() *ZodTuple[T, *[]any]

Optional marks this tuple as optional

func (*ZodTuple[T, R]) Parse added in v0.5.4

func (z *ZodTuple[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using tuple-specific parsing logic with engine.ParseComplex

func (*ZodTuple[T, R]) ParseAny added in v0.5.4

func (z *ZodTuple[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodTuple[T, R]) Refine added in v0.5.4

func (z *ZodTuple[T, R]) Refine(fn func([]any) bool, params ...any) *ZodTuple[T, R]

Refine adds custom validation logic

func (*ZodTuple[T, R]) Rest added in v0.5.4

func (z *ZodTuple[T, R]) Rest(restSchema core.ZodSchema) *ZodTuple[T, R]

Rest sets a rest element schema for additional elements beyond fixed items TypeScript Zod v4 equivalent: tuple.rest(schema)

func (*ZodTuple[T, R]) StrictParse added in v0.5.4

func (z *ZodTuple[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance.

func (*ZodTuple[T, R]) With added in v0.5.4

func (z *ZodTuple[T, R]) With(check core.ZodCheck) *ZodTuple[T, R]

With is an alias for Check (TypeScript Zod v4 compatibility)

type ZodTupleDef added in v0.5.4

type ZodTupleDef struct {
	core.ZodTypeDef
	Items []core.ZodSchema // Fixed positional item schemas
	Rest  core.ZodSchema   // Rest element schema (optional, for variadic elements)
}

ZodTupleDef defines the schema definition for tuple validation TypeScript Zod v4 equivalent: $ZodTupleDef

type ZodTupleInternals added in v0.5.4

type ZodTupleInternals struct {
	core.ZodTypeInternals
	Def           *ZodTupleDef     // Schema definition reference
	Items         []core.ZodSchema // Item schemas for runtime validation
	Rest          core.ZodSchema   // Rest element schema
	RequiredCount int              // Number of required items (up to first optional from end)
}

ZodTupleInternals contains the internal state for tuple schema

type ZodULID added in v0.3.0

type ZodULID[T StringConstraint] struct{ *ZodString[T] }

func Ulid added in v0.3.0

func Ulid(params ...any) *ZodULID[string]

func UlidPtr added in v0.3.0

func UlidPtr(params ...any) *ZodULID[*string]

func (*ZodULID[T]) MustStrictParse added in v0.4.0

func (z *ZodULID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodULID[T]) StrictParse added in v0.4.0

func (z *ZodULID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodURL added in v0.3.0

type ZodURL[T NetworkConstraint] struct {
	// contains filtered or unexported fields
}

ZodURL represents a URL validation schema

func CoercedURL added in v0.3.0

func CoercedURL(params ...any) *ZodURL[string]

CoercedURL creates coerced URL schema that attempts string conversion

func HttpURL added in v0.5.4

func HttpURL(params ...any) *ZodURL[string]

HttpURL creates an HTTP/HTTPS URL schema This is a convenience function that creates a URL schema restricted to http:// and https:// protocols with domain hostname validation.

TypeScript Zod v4 equivalent: z.httpUrl()

Examples:

schema := HttpURL()
schema.Parse("https://example.com")      // valid
schema.Parse("http://sub.example.com")   // valid
schema.Parse("ftp://example.com")        // invalid - not http/https
schema.Parse("http://localhost")         // invalid - not a domain

func HttpURLPtr added in v0.5.4

func HttpURLPtr(params ...any) *ZodURL[*string]

HttpURLPtr creates an HTTP/HTTPS URL schema for pointer types

func HttpURLTyped added in v0.5.4

func HttpURLTyped[T NetworkConstraint](params ...any) *ZodURL[T]

HttpURLTyped creates an HTTP/HTTPS URL schema with specific type

func URL added in v0.3.0

func URL(params ...any) *ZodURL[string]

URL creates a new URL schema with flexible parameter support Supports various parameter combinations:

URL() - basic URL schema
URL("error message") - with custom error message
URL(URLOptions{Hostname: pattern}) - with URL options
URL(URLOptions{...}, "error message") - options with error message
URL(URLOptions{...}, core.SchemaParams{Description: "URL"}) - options with schema params
URL(core.SchemaParams{Description: "URL"}) - with schema parameters only

func URLPtr added in v0.3.0

func URLPtr(params ...any) *ZodURL[*string]

URLPtr creates a new URL schema with pointer type and flexible parameter support Supports the same parameter combinations as URL() but returns *ZodURL[*string]

func URLTyped added in v0.3.0

func URLTyped[T NetworkConstraint](params ...any) *ZodURL[T]

URLTyped creates a new URL schema with specific type and flexible parameter support

func (*ZodURL[T]) CloneFrom added in v0.3.0

func (z *ZodURL[T]) CloneFrom(source any)

CloneFrom clones internals from another ZodURL instance

func (*ZodURL[T]) Coerce added in v0.3.0

func (z *ZodURL[T]) Coerce(input any) (any, bool)

Coerce implements type conversion interface using coerce package

func (*ZodURL[T]) Default added in v0.3.0

func (z *ZodURL[T]) Default(v string) *ZodURL[T]

Default preserves current generic type T

func (*ZodURL[T]) DefaultFunc added in v0.3.0

func (z *ZodURL[T]) DefaultFunc(fn func() string) *ZodURL[T]

DefaultFunc preserves current generic type T

func (*ZodURL[T]) GetInternals added in v0.3.0

func (z *ZodURL[T]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodURL[T]) IsNilable added in v0.3.0

func (z *ZodURL[T]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodURL[T]) IsOptional added in v0.3.0

func (z *ZodURL[T]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodURL[T]) MustParse added in v0.3.0

func (z *ZodURL[T]) MustParse(input any, ctx ...*core.ParseContext) T

MustParse is the variant that panics on error

func (*ZodURL[T]) MustStrictParse added in v0.4.0

func (z *ZodURL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse is the strict mode variant that panics on error. Provides compile-time type safety with maximum performance.

func (*ZodURL[T]) Nilable added in v0.3.0

func (z *ZodURL[T]) Nilable() *ZodURL[*string]

Nilable allows nil values, returns pointer type

func (*ZodURL[T]) Nullish added in v0.3.0

func (z *ZodURL[T]) Nullish() *ZodURL[*string]

Nullish combines optional and nilable modifiers

func (*ZodURL[T]) Optional added in v0.3.0

func (z *ZodURL[T]) Optional() *ZodURL[*string]

Optional allows nil values, returns pointer type for nullable semantics

func (*ZodURL[T]) Parse added in v0.3.0

func (z *ZodURL[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)

Parse returns type-safe URL using unified engine API

func (*ZodURL[T]) ParseAny added in v0.3.0

func (z *ZodURL[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodURL[T]) Prefault added in v0.3.0

func (z *ZodURL[T]) Prefault(v string) *ZodURL[T]

Prefault provides fallback values on validation failure

func (*ZodURL[T]) PrefaultFunc added in v0.3.0

func (z *ZodURL[T]) PrefaultFunc(fn func() string) *ZodURL[T]

PrefaultFunc provides dynamic fallback values

func (*ZodURL[T]) Refine added in v0.3.0

func (z *ZodURL[T]) Refine(fn func(T) bool, params ...any) *ZodURL[T]

Refine adds type-safe custom validation logic

func (*ZodURL[T]) RefineAny added in v0.3.0

func (z *ZodURL[T]) RefineAny(fn func(any) bool, params ...any) *ZodURL[T]

RefineAny adds a custom refinement function for any type

func (*ZodURL[T]) StrictParse added in v0.4.0

func (z *ZodURL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

type ZodURLDef added in v0.3.0

type ZodURLDef struct {
	core.ZodTypeDef
}

ZodURLDef defines the configuration for URL validation

type ZodURLInternals added in v0.3.0

type ZodURLInternals struct {
	core.ZodTypeInternals
	Def *ZodURLDef // Schema definition
}

ZodURLInternals contains URL validator internal state

type ZodUUID added in v0.3.0

type ZodUUID[T StringConstraint] struct{ *ZodString[T] }

func Uuid added in v0.3.0

func Uuid(params ...any) *ZodUUID[string]

Uuid supports optional version parameter: "v4", "v6", "v7". Otherwise behaves like generic UUID validator.

func UuidPtr added in v0.3.0

func UuidPtr(params ...any) *ZodUUID[*string]

func Uuidv4 added in v0.3.0

func Uuidv4(params ...any) *ZodUUID[string]

func Uuidv4Ptr added in v0.3.0

func Uuidv4Ptr(params ...any) *ZodUUID[*string]

func Uuidv6 added in v0.3.0

func Uuidv6(params ...any) *ZodUUID[string]

func Uuidv6Ptr added in v0.3.0

func Uuidv6Ptr(params ...any) *ZodUUID[*string]

func Uuidv7 added in v0.3.0

func Uuidv7(params ...any) *ZodUUID[string]

func Uuidv7Ptr added in v0.3.0

func Uuidv7Ptr(params ...any) *ZodUUID[*string]

func (*ZodUUID[T]) MustStrictParse added in v0.4.0

func (z *ZodUUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodUUID[T]) StrictParse added in v0.4.0

func (z *ZodUUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodUnion

type ZodUnion[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodUnion represents a union validation schema with dual generic parameters T = base type (any), R = constraint type (any or *any)

func Union

func Union(options []any, args ...any) *ZodUnion[any, any]

Union creates union schema that accepts one of multiple types - returns value constraint

func UnionOf added in v0.3.0

func UnionOf(schemas ...any) *ZodUnion[any, any]

UnionOf creates union schema from variadic arguments - returns value constraint

func UnionOfPtr added in v0.3.0

func UnionOfPtr(schemas ...any) *ZodUnion[any, *any]

UnionOfPtr creates union schema from variadic arguments - returns pointer constraint

func UnionPtr added in v0.3.0

func UnionPtr(options []any, args ...any) *ZodUnion[any, *any]

UnionPtr creates union schema that accepts one of multiple types - returns pointer constraint

func UnionTyped added in v0.3.0

func UnionTyped[T any, R any](options []any, args ...any) *ZodUnion[T, R]

UnionTyped creates typed union schema with generic constraints

func (*ZodUnion[T, R]) And added in v0.5.4

func (z *ZodUnion[T, R]) And(other any) *ZodIntersection[any, any]

And creates an intersection with another schema. Enables chaining: schema.And(other).And(another) TypeScript Zod v4 equivalent: schema.and(other)

Example:

schema := gozod.String().Or(gozod.Int()).And(gozod.Bool())

func (*ZodUnion[T, R]) CloneFrom

func (z *ZodUnion[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodUnion[T, R]) Default

func (z *ZodUnion[T, R]) Default(v T) *ZodUnion[T, R]

Default preserves current constraint type R

func (*ZodUnion[T, R]) DefaultFunc

func (z *ZodUnion[T, R]) DefaultFunc(fn func() T) *ZodUnion[T, R]

DefaultFunc preserves current constraint type R

func (*ZodUnion[T, R]) Describe added in v0.5.4

func (z *ZodUnion[T, R]) Describe(description string) *ZodUnion[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

Example:

schema := gozod.Union(gozod.String(), gozod.Int()).Describe("String or integer value")

func (*ZodUnion[T, R]) GetInternals

func (z *ZodUnion[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodUnion[T, R]) IsNilable added in v0.3.0

func (z *ZodUnion[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodUnion[T, R]) IsOptional added in v0.3.0

func (z *ZodUnion[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodUnion[T, R]) Meta added in v0.3.1

func (z *ZodUnion[T, R]) Meta(meta core.GlobalMeta) *ZodUnion[T, R]

Meta stores metadata for this union schema.

func (*ZodUnion[T, R]) MustParse

func (z *ZodUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodUnion[T, R]) MustStrictParse added in v0.4.0

func (z *ZodUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates input with compile-time type safety and panics on failure

func (*ZodUnion[T, R]) Nilable

func (z *ZodUnion[T, R]) Nilable() *ZodUnion[T, *T]

Nilable allows nil values and returns pointer constraint

func (*ZodUnion[T, R]) NonOptional added in v0.3.0

func (z *ZodUnion[T, R]) NonOptional() *ZodUnion[T, T]

NonOptional removes Optional flag and enforces non-nil value (T).

func (*ZodUnion[T, R]) Nullish added in v0.3.0

func (z *ZodUnion[T, R]) Nullish() *ZodUnion[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodUnion[T, R]) Optional

func (z *ZodUnion[T, R]) Optional() *ZodUnion[T, *T]

Optional creates optional union schema that returns pointer constraint

func (*ZodUnion[T, R]) Options

func (z *ZodUnion[T, R]) Options() []core.ZodSchema

Options returns all union member schemas

func (*ZodUnion[T, R]) Or added in v0.5.4

func (z *ZodUnion[T, R]) Or(other any) *ZodUnion[any, any]

Or creates a union with another schema, enabling chaining. Enables chaining: schema.Or(other).Or(another) TypeScript Zod v4 equivalent: schema.or(other)

Example:

schema := gozod.String().Or(gozod.Int()).Or(gozod.Bool())
result, _ := schema.Parse("hello")  // Accepts string
result, _ = schema.Parse(42)        // Accepts int
result, _ = schema.Parse(true)      // Accepts bool

func (*ZodUnion[T, R]) Parse

func (z *ZodUnion[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input using engine.ParseComplex for unified Default/Prefault handling

func (*ZodUnion[T, R]) ParseAny added in v0.3.0

func (z *ZodUnion[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns untyped result for runtime scenarios. Zero-overhead wrapper around Parse to eliminate reflection calls.

func (*ZodUnion[T, R]) Pipe

func (z *ZodUnion[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates validation pipeline to another schema using WrapFn pattern

func (*ZodUnion[T, R]) Prefault

func (z *ZodUnion[T, R]) Prefault(v T) *ZodUnion[T, R]

Prefault provides fallback values on validation failure

func (*ZodUnion[T, R]) PrefaultFunc

func (z *ZodUnion[T, R]) PrefaultFunc(fn func() T) *ZodUnion[T, R]

PrefaultFunc keeps current generic type R.

func (*ZodUnion[T, R]) Refine

func (z *ZodUnion[T, R]) Refine(fn func(R) bool, params ...any) *ZodUnion[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodUnion[T, R]) RefineAny

func (z *ZodUnion[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodUnion[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodUnion[T, R]) StrictParse added in v0.4.0

func (z *ZodUnion[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates input with compile-time type safety and enhanced performance StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type T.

func (*ZodUnion[T, R]) Transform

func (z *ZodUnion[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates type-safe transformation pipeline using WrapFn pattern

type ZodUnionDef

type ZodUnionDef struct {
	core.ZodTypeDef
	Options []core.ZodSchema // Union member schemas using unified interface
}

ZodUnionDef defines the schema definition for union validation

type ZodUnionInternals

type ZodUnionInternals struct {
	core.ZodTypeInternals
	Def     *ZodUnionDef     // Schema definition reference
	Options []core.ZodSchema // Union member schemas for runtime validation
}

ZodUnionInternals contains the internal state for union schema

type ZodUnknown

type ZodUnknown[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodUnknown represents an unknown-value validation schema with dual generic parameters T = base type (any), R = constraint type (any or *any) Unknown accepts any value but provides validation and modifier support

func Unknown

func Unknown(params ...any) *ZodUnknown[any, any]

Unknown creates unknown schema that accepts any value - returns value constraint

func UnknownPtr added in v0.3.0

func UnknownPtr(params ...any) *ZodUnknown[any, *any]

UnknownPtr creates unknown schema that accepts any value - returns pointer constraint

func UnknownTyped added in v0.3.0

func UnknownTyped[T any, R any](params ...any) *ZodUnknown[T, R]

UnknownTyped creates typed unknown schema with generic constraints

func (*ZodUnknown[T, R]) CloneFrom

func (z *ZodUnknown[T, R]) CloneFrom(source any)

CloneFrom copies configuration from another schema

func (*ZodUnknown[T, R]) Default

func (z *ZodUnknown[T, R]) Default(v T) *ZodUnknown[T, R]

Default preserves current constraint type R

func (*ZodUnknown[T, R]) DefaultFunc

func (z *ZodUnknown[T, R]) DefaultFunc(fn func() T) *ZodUnknown[T, R]

DefaultFunc preserves current constraint type R

func (*ZodUnknown[T, R]) Describe added in v0.5.4

func (z *ZodUnknown[T, R]) Describe(description string) *ZodUnknown[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

func (*ZodUnknown[T, R]) GetInternals

func (z *ZodUnknown[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals returns the internal state of the schema

func (*ZodUnknown[T, R]) IsNilable added in v0.3.0

func (z *ZodUnknown[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodUnknown[T, R]) IsOptional added in v0.3.0

func (z *ZodUnknown[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodUnknown[T, R]) Meta added in v0.3.1

func (z *ZodUnknown[T, R]) Meta(meta core.GlobalMeta) *ZodUnknown[T, R]

Meta stores metadata for this unknown schema.

func (*ZodUnknown[T, R]) MustParse

func (z *ZodUnknown[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse is the variant that panics on error

func (*ZodUnknown[T, R]) MustStrictParse added in v0.4.0

func (z *ZodUnknown[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R

MustStrictParse provides compile-time type safety and panics on validation failure. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodUnknown[T, R]) Nilable

func (z *ZodUnknown[T, R]) Nilable() *ZodUnknown[T, *T]

Nilable makes the unknown type nilable and returns pointer constraint

func (*ZodUnknown[T, R]) NonOptional added in v0.3.0

func (z *ZodUnknown[T, R]) NonOptional() *ZodUnknown[T, T]

NonOptional makes the unknown type non-optional and returns base type constraint

func (*ZodUnknown[T, R]) Nullish

func (z *ZodUnknown[T, R]) Nullish() *ZodUnknown[T, *T]

Nullish combines optional and nilable modifiers

func (*ZodUnknown[T, R]) Optional

func (z *ZodUnknown[T, R]) Optional() *ZodUnknown[T, *T]

Optional makes the unknown type optional and returns pointer constraint

func (*ZodUnknown[T, R]) Overwrite added in v0.3.0

func (z *ZodUnknown[T, R]) Overwrite(transform func(T) T, params ...any) *ZodUnknown[T, R]

Overwrite applies data transformation while preserving type structure This allows for data cleaning, normalization, and preprocessing operations Unknown type's Overwrite is particularly useful for sanitizing unpredictable data

func (*ZodUnknown[T, R]) Parse

func (z *ZodUnknown[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse returns the input value as-is with full modifier and validation support using unified engine parsing Unknown type has special behavior: it accepts nil by default (unlike other types)

func (*ZodUnknown[T, R]) ParseAny added in v0.3.0

func (z *ZodUnknown[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates the input value and returns any type (for runtime interface)

func (*ZodUnknown[T, R]) Pipe

func (z *ZodUnknown[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]

Pipe creates validation pipeline to another schema using WrapFn pattern

func (*ZodUnknown[T, R]) Prefault

func (z *ZodUnknown[T, R]) Prefault(v T) *ZodUnknown[T, R]

Prefault provides fallback values on validation failure

func (*ZodUnknown[T, R]) PrefaultFunc

func (z *ZodUnknown[T, R]) PrefaultFunc(fn func() T) *ZodUnknown[T, R]

PrefaultFunc provides dynamic fallback values

func (*ZodUnknown[T, R]) Refine

func (z *ZodUnknown[T, R]) Refine(fn func(R) bool, args ...any) *ZodUnknown[T, R]

Refine applies type-safe validation with constraint type R

func (*ZodUnknown[T, R]) RefineAny

func (z *ZodUnknown[T, R]) RefineAny(fn func(any) bool, args ...any) *ZodUnknown[T, R]

RefineAny provides flexible validation without type conversion

func (*ZodUnknown[T, R]) StrictParse added in v0.4.0

func (z *ZodUnknown[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)

StrictParse provides compile-time type safety by requiring exact type matching. This eliminates runtime type checking overhead for maximum performance. The input must exactly match the schema's constraint type R.

func (*ZodUnknown[T, R]) Transform

func (z *ZodUnknown[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]

Transform creates type-safe transformation pipeline using WrapFn pattern

type ZodUnknownDef

type ZodUnknownDef struct {
	core.ZodTypeDef
}

ZodUnknownDef defines the configuration for unknown value validation

type ZodUnknownInternals

type ZodUnknownInternals struct {
	core.ZodTypeInternals
	Def *ZodUnknownDef // Schema definition
}

ZodUnknownInternals contains unknown validator internal state

type ZodXID added in v0.3.0

type ZodXID[T StringConstraint] struct{ *ZodString[T] }

func Xid added in v0.3.0

func Xid(params ...any) *ZodXID[string]

func XidPtr added in v0.3.0

func XidPtr(params ...any) *ZodXID[*string]

func (*ZodXID[T]) MustStrictParse added in v0.4.0

func (z *ZodXID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T

MustStrictParse validates the input using strict parsing rules and panics on error

func (*ZodXID[T]) StrictParse added in v0.4.0

func (z *ZodXID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)

StrictParse validates the input using strict parsing rules

type ZodXor added in v0.5.4

type ZodXor[T any, R any] struct {
	// contains filtered or unexported fields
}

ZodXor represents an exclusive union validation schema (exactly one must match) T = base type (any), R = constraint type (any or *any)

func Xor added in v0.5.4

func Xor(options []any, args ...any) *ZodXor[any, any]

Xor creates exclusive union schema that requires exactly one option to match Unlike Union which succeeds when any option matches, Xor fails if zero or multiple match.

func XorOf added in v0.5.4

func XorOf(schemas ...any) *ZodXor[any, any]

XorOf creates exclusive union schema from variadic arguments

func XorOfPtr added in v0.5.4

func XorOfPtr(schemas ...any) *ZodXor[any, *any]

XorOfPtr creates exclusive union schema from variadic arguments returning pointer

func XorPtr added in v0.5.4

func XorPtr(options []any, args ...any) *ZodXor[any, *any]

XorPtr creates exclusive union schema returning pointer constraint

func XorTyped added in v0.5.4

func XorTyped[T any, R any](options []any, args ...any) *ZodXor[T, R]

XorTyped creates typed exclusive union schema with generic constraints

func (*ZodXor[T, R]) Describe added in v0.5.4

func (z *ZodXor[T, R]) Describe(description string) *ZodXor[T, R]

Describe registers a description in the global registry. TypeScript Zod v4 equivalent: schema.describe(description)

Example:

schema := gozod.Xor(gozod.String(), gozod.Int()).Describe("Exactly one of string or integer")

func (*ZodXor[T, R]) GetInternals added in v0.5.4

func (z *ZodXor[T, R]) GetInternals() *core.ZodTypeInternals

GetInternals exposes internal state for framework usage

func (*ZodXor[T, R]) IsNilable added in v0.5.4

func (z *ZodXor[T, R]) IsNilable() bool

IsNilable returns true if this schema accepts nil values

func (*ZodXor[T, R]) IsOptional added in v0.5.4

func (z *ZodXor[T, R]) IsOptional() bool

IsOptional returns true if this schema accepts undefined/missing values

func (*ZodXor[T, R]) Meta added in v0.5.4

func (z *ZodXor[T, R]) Meta(meta core.GlobalMeta) *ZodXor[T, R]

Meta stores metadata for this exclusive union schema

func (*ZodXor[T, R]) MustParse added in v0.5.4

func (z *ZodXor[T, R]) MustParse(input any, ctx ...*core.ParseContext) R

MustParse validates the input value and panics on failure

func (*ZodXor[T, R]) MustStrictParse added in v0.5.4

func (z *ZodXor[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R

MustStrictParse validates the input value with compile-time type safety and panics on failure

func (*ZodXor[T, R]) Options added in v0.5.4

func (z *ZodXor[T, R]) Options() []core.ZodSchema

Options returns the union member schemas for JSON Schema conversion

func (*ZodXor[T, R]) Parse added in v0.5.4

func (z *ZodXor[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)

Parse validates input ensuring exactly one option matches

func (*ZodXor[T, R]) ParseAny added in v0.5.4

func (z *ZodXor[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)

ParseAny validates input and returns any type

func (*ZodXor[T, R]) StrictParse added in v0.5.4

func (z *ZodXor[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)

StrictParse validates input with compile-time type safety

type ZodXorDef added in v0.5.4

type ZodXorDef struct {
	core.ZodTypeDef
	Options []core.ZodSchema // Union member schemas
}

ZodXorDef defines the schema definition for exclusive union validation

type ZodXorInternals added in v0.5.4

type ZodXorInternals struct {
	core.ZodTypeInternals
	Def     *ZodXorDef       // Schema definition reference
	Options []core.ZodSchema // Union member schemas for runtime validation
}

ZodXorInternals contains the internal state for exclusive union schema

Jump to

Keyboard shortcuts

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