Documentation
¶
Overview ¶
Package types provides public schema implementations for GoZod validation types.
Index ¶
- Variables
- func ValidateStruct(value any, opts ...FromStructOption) (any, error)
- type BigIntegerConstraint
- type BoolConstraint
- type Complex64Constraint
- type Complex128Constraint
- type ComplexConstraint
- type EmailConstraint
- type FloatConstraint
- type FromStructOption
- type FunctionConstraint
- type FunctionParams
- type IntegerConstraint
- type IsoConstraint
- type IsoDatetimeOptions
- type IsoTimeOptions
- type JWTOptions
- type LazyConstraint
- type ObjectMode
- type StringBoolConstraint
- type StringBoolOptions
- type StringConstraint
- type TimeConstraint
- type TupleConstraint
- type URLOptions
- type ZodAny
- func (z *ZodAny[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodAny[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodAny[T, R]
- func (z *ZodAny[T, R]) CloneFrom(source any)
- func (z *ZodAny[T, R]) Default(v T) *ZodAny[T, R]
- func (z *ZodAny[T, R]) DefaultFunc(fn func() T) *ZodAny[T, R]
- func (z *ZodAny[T, R]) Describe(desc string) *ZodAny[T, R]
- func (z *ZodAny[T, R]) ExactOptional() *ZodAny[T, R]
- func (z *ZodAny[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodAny[T, R]) IsNilable() bool
- func (z *ZodAny[T, R]) IsOptional() bool
- func (z *ZodAny[T, R]) Meta(meta core.GlobalMeta) *ZodAny[T, R]
- func (z *ZodAny[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodAny[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodAny[T, R]) Nilable() *ZodAny[T, *T]
- func (z *ZodAny[T, R]) NonOptional() *ZodAny[T, T]
- func (z *ZodAny[T, R]) Nullish() *ZodAny[T, *T]
- func (z *ZodAny[T, R]) Optional() *ZodAny[T, *T]
- func (z *ZodAny[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodAny[T, R]) Overwrite(transform func(T) T, params ...any) *ZodAny[T, R]
- func (z *ZodAny[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodAny[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodAny[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodAny[T, R]) Prefault(v T) *ZodAny[T, R]
- func (z *ZodAny[T, R]) PrefaultFunc(fn func() T) *ZodAny[T, R]
- func (z *ZodAny[T, R]) Refine(fn func(R) bool, params ...any) *ZodAny[T, R]
- func (z *ZodAny[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodAny[T, R]
- func (z *ZodAny[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodAny[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodAny[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodAny[T, R]
- type ZodAnyDef
- type ZodAnyInternals
- type ZodArray
- func (z *ZodArray[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodArray[T, R]) Check(fn func(R, *core.ParsePayload), params ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) CloneFrom(source any)
- func (z *ZodArray[T, R]) Default(v T) *ZodArray[T, R]
- func (z *ZodArray[T, R]) DefaultFunc(fn func() T) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Describe(description string) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Element(index int) core.ZodSchema
- func (z *ZodArray[T, R]) ExactOptional() *ZodArray[T, R]
- func (z *ZodArray[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodArray[T, R]) IsNilable() bool
- func (z *ZodArray[T, R]) IsOptional() bool
- func (z *ZodArray[T, R]) Items() []core.ZodSchema
- func (z *ZodArray[T, R]) Length(n int, args ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Max(n int, args ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Meta(meta core.GlobalMeta) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Min(n int, args ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodArray[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodArray[T, R]) Nilable() *ZodArray[T, *T]
- func (z *ZodArray[T, R]) NonEmpty(args ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) NonOptional() *ZodArray[T, T]
- func (z *ZodArray[T, R]) Nullish() *ZodArray[T, *T]
- func (z *ZodArray[T, R]) Optional() *ZodArray[T, *T]
- func (z *ZodArray[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodArray[T, R]) Overwrite(fn func(R) R, params ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodArray[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodArray[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodArray[T, R]) Prefault(v T) *ZodArray[T, R]
- func (z *ZodArray[T, R]) PrefaultFunc(fn func() T) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Refine(fn func(R) bool, params ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodArray[T, R]
- func (z *ZodArray[T, R]) Rest() core.ZodSchema
- func (z *ZodArray[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodArray[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- type ZodArrayDef
- type ZodArrayInternals
- type ZodBase64
- func (z *ZodBase64[T]) Default(v string) *ZodBase64[T]
- func (z *ZodBase64[T]) DefaultFunc(fn func() string) *ZodBase64[T]
- func (z *ZodBase64[T]) Describe(description string) *ZodBase64[T]
- func (z *ZodBase64[T]) Meta(meta core.GlobalMeta) *ZodBase64[T]
- func (z *ZodBase64[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodBase64[T]) Nilable() *ZodBase64[*string]
- func (z *ZodBase64[T]) Nullish() *ZodBase64[*string]
- func (z *ZodBase64[T]) Optional() *ZodBase64[*string]
- func (z *ZodBase64[T]) Prefault(v string) *ZodBase64[T]
- func (z *ZodBase64[T]) PrefaultFunc(fn func() string) *ZodBase64[T]
- func (z *ZodBase64[T]) RefineAny(fn func(any) bool, params ...any) *ZodBase64[T]
- func (z *ZodBase64[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodBase64URL
- func (z *ZodBase64URL[T]) Default(v string) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) DefaultFunc(fn func() string) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) Describe(description string) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) Meta(meta core.GlobalMeta) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodBase64URL[T]) Nilable() *ZodBase64URL[*string]
- func (z *ZodBase64URL[T]) Nullish() *ZodBase64URL[*string]
- func (z *ZodBase64URL[T]) Optional() *ZodBase64URL[*string]
- func (z *ZodBase64URL[T]) Prefault(v string) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) PrefaultFunc(fn func() string) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) RefineAny(fn func(any) bool, params ...any) *ZodBase64URL[T]
- func (z *ZodBase64URL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodBigInt
- func (z *ZodBigInt[T]) CloneFrom(src any)
- func (z *ZodBigInt[T]) Coerce(input any) (any, bool)
- func (z *ZodBigInt[T]) Default(v *big.Int) *ZodBigInt[T]
- func (z *ZodBigInt[T]) DefaultFunc(fn func() *big.Int) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Describe(desc string) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Gt(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Gte(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Internals() *core.ZodTypeInternals
- func (z *ZodBigInt[T]) IsNilable() bool
- func (z *ZodBigInt[T]) IsOptional() bool
- func (z *ZodBigInt[T]) Lt(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Lte(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Max(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Meta(meta core.GlobalMeta) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Min(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) MultipleOf(n *big.Int, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodBigInt[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodBigInt[T]) Negative(params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Nilable() *ZodBigInt[**big.Int]
- func (z *ZodBigInt[T]) NonNegative(params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) NonOptional() *ZodBigInt[*big.Int]
- func (z *ZodBigInt[T]) NonPositive(params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Nullish() *ZodBigInt[**big.Int]
- func (z *ZodBigInt[T]) Optional() *ZodBigInt[**big.Int]
- func (z *ZodBigInt[T]) Overwrite(transform func(T) T, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodBigInt[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodBigInt[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodBigInt[T]) Positive(params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Prefault(v *big.Int) *ZodBigInt[T]
- func (z *ZodBigInt[T]) PrefaultFunc(fn func() *big.Int) *ZodBigInt[T]
- func (z *ZodBigInt[T]) Refine(fn func(T) bool, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) RefineAny(fn func(any) bool, params ...any) *ZodBigInt[T]
- func (z *ZodBigInt[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodBigInt[T]) Transform(fn func(*big.Int, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- type ZodBigIntDef
- type ZodBigIntInternals
- type ZodBool
- func (z *ZodBool[T]) And(other any) *ZodIntersection[any, any]
- func (z *ZodBool[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodBool[T]
- func (z *ZodBool[T]) CloneFrom(source any)
- func (z *ZodBool[T]) Coerce(input any) (any, bool)
- func (z *ZodBool[T]) Default(v bool) *ZodBool[T]
- func (z *ZodBool[T]) DefaultFunc(fn func() bool) *ZodBool[T]
- func (z *ZodBool[T]) Describe(desc string) *ZodBool[T]
- func (z *ZodBool[T]) ExactOptional() *ZodBool[T]
- func (z *ZodBool[T]) Internals() *core.ZodTypeInternals
- func (z *ZodBool[T]) IsNilable() bool
- func (z *ZodBool[T]) IsOptional() bool
- func (z *ZodBool[T]) Meta(meta core.GlobalMeta) *ZodBool[T]
- func (z *ZodBool[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodBool[T]) Nilable() *ZodBool[*bool]
- func (z *ZodBool[T]) NonOptional() *ZodBool[bool]
- func (z *ZodBool[T]) Nullish() *ZodBool[*bool]
- func (z *ZodBool[T]) Optional() *ZodBool[*bool]
- func (z *ZodBool[T]) Or(other any) *ZodUnion[any, any]
- func (z *ZodBool[T]) Overwrite(transform func(T) T, params ...any) *ZodBool[T]
- func (z *ZodBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodBool[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodBool[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodBool[T]) Prefault(v bool) *ZodBool[T]
- func (z *ZodBool[T]) PrefaultFunc(fn func() bool) *ZodBool[T]
- func (z *ZodBool[T]) Refine(fn func(T) bool, params ...any) *ZodBool[T]
- func (z *ZodBool[T]) RefineAny(fn func(any) bool, params ...any) *ZodBool[T]
- func (z *ZodBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodBool[T]) Transform(fn func(bool, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- func (z *ZodBool[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodBool[T]
- type ZodBoolDef
- type ZodBoolInternals
- type ZodCIDRv4
- func (z *ZodCIDRv4[T]) Default(v string) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) DefaultFunc(fn func() string) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) Describe(description string) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) Meta(meta core.GlobalMeta) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodCIDRv4[T]) Nilable() *ZodCIDRv4[*string]
- func (z *ZodCIDRv4[T]) Nullish() *ZodCIDRv4[*string]
- func (z *ZodCIDRv4[T]) Optional() *ZodCIDRv4[*string]
- func (z *ZodCIDRv4[T]) Prefault(v string) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) PrefaultFunc(fn func() string) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) RefineAny(fn func(any) bool, params ...any) *ZodCIDRv4[T]
- func (z *ZodCIDRv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodCIDRv6
- func (z *ZodCIDRv6[T]) Default(v string) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) DefaultFunc(fn func() string) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) Describe(description string) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) Meta(meta core.GlobalMeta) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodCIDRv6[T]) Nilable() *ZodCIDRv6[*string]
- func (z *ZodCIDRv6[T]) Nullish() *ZodCIDRv6[*string]
- func (z *ZodCIDRv6[T]) Optional() *ZodCIDRv6[*string]
- func (z *ZodCIDRv6[T]) Prefault(v string) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) PrefaultFunc(fn func() string) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) RefineAny(fn func(any) bool, params ...any) *ZodCIDRv6[T]
- func (z *ZodCIDRv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodCUID
- func (z *ZodCUID[T]) Default(v string) *ZodCUID[T]
- func (z *ZodCUID[T]) DefaultFunc(fn func() string) *ZodCUID[T]
- func (z *ZodCUID[T]) Describe(description string) *ZodCUID[T]
- func (z *ZodCUID[T]) Meta(meta core.GlobalMeta) *ZodCUID[T]
- func (z *ZodCUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodCUID[T]) Nilable() *ZodCUID[*string]
- func (z *ZodCUID[T]) Nullish() *ZodCUID[*string]
- func (z *ZodCUID[T]) Optional() *ZodCUID[*string]
- func (z *ZodCUID[T]) Prefault(v string) *ZodCUID[T]
- func (z *ZodCUID[T]) PrefaultFunc(fn func() string) *ZodCUID[T]
- func (z *ZodCUID[T]) RefineAny(fn func(any) bool, params ...any) *ZodCUID[T]
- func (z *ZodCUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodCUID2
- func (z *ZodCUID2[T]) Default(v string) *ZodCUID2[T]
- func (z *ZodCUID2[T]) DefaultFunc(fn func() string) *ZodCUID2[T]
- func (z *ZodCUID2[T]) Describe(description string) *ZodCUID2[T]
- func (z *ZodCUID2[T]) Meta(meta core.GlobalMeta) *ZodCUID2[T]
- func (z *ZodCUID2[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodCUID2[T]) Nilable() *ZodCUID2[*string]
- func (z *ZodCUID2[T]) Nullish() *ZodCUID2[*string]
- func (z *ZodCUID2[T]) Optional() *ZodCUID2[*string]
- func (z *ZodCUID2[T]) Prefault(v string) *ZodCUID2[T]
- func (z *ZodCUID2[T]) PrefaultFunc(fn func() string) *ZodCUID2[T]
- func (z *ZodCUID2[T]) RefineAny(fn func(any) bool, params ...any) *ZodCUID2[T]
- func (z *ZodCUID2[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodComplex
- func CoercedComplex(params ...any) *ZodComplex[complex128]
- func CoercedComplex64(params ...any) *ZodComplex[complex64]
- func CoercedComplex64Ptr(params ...any) *ZodComplex[*complex64]
- func CoercedComplex128(params ...any) *ZodComplex[complex128]
- func CoercedComplex128Ptr(params ...any) *ZodComplex[*complex128]
- func CoercedComplexPtr(params ...any) *ZodComplex[*complex128]
- func Complex(params ...any) *ZodComplex[complex128]
- func Complex64(params ...any) *ZodComplex[complex64]
- func Complex64Ptr(params ...any) *ZodComplex[*complex64]
- func Complex128(params ...any) *ZodComplex[complex128]
- func Complex128Ptr(params ...any) *ZodComplex[*complex128]
- func ComplexPtr(params ...any) *ZodComplex[*complex128]
- func ComplexTyped[T ComplexConstraint](params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) And(other any) *ZodIntersection[any, any]
- func (z *ZodComplex[T]) CloneFrom(source any)
- func (z *ZodComplex[T]) Coerce(input any) (any, bool)
- func (z *ZodComplex[T]) Default(v complex128) *ZodComplex[T]
- func (z *ZodComplex[T]) DefaultFunc(fn func() complex128) *ZodComplex[T]
- func (z *ZodComplex[T]) Describe(desc string) *ZodComplex[T]
- func (z *ZodComplex[T]) ExactOptional() *ZodComplex[T]
- func (z *ZodComplex[T]) Finite(params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Gt(value float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Gte(value float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Internals() *core.ZodTypeInternals
- func (z *ZodComplex[T]) IsNilable() bool
- func (z *ZodComplex[T]) IsOptional() bool
- func (z *ZodComplex[T]) Lt(value float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Lte(value float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Max(maximum float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Meta(meta core.GlobalMeta) *ZodComplex[T]
- func (z *ZodComplex[T]) Min(minimum float64, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodComplex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodComplex[T]) Negative(params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Nilable() *ZodComplex[*complex128]
- func (z *ZodComplex[T]) NonNegative(params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) NonPositive(params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Nullish() *ZodComplex[*complex128]
- func (z *ZodComplex[T]) Optional() *ZodComplex[*complex128]
- func (z *ZodComplex[T]) Or(other any) *ZodUnion[any, any]
- func (z *ZodComplex[T]) Overwrite(transform func(T) T, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodComplex[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodComplex[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodComplex[T]) Positive(params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) Prefault(v complex128) *ZodComplex[T]
- func (z *ZodComplex[T]) PrefaultFunc(fn func() complex128) *ZodComplex[T]
- func (z *ZodComplex[T]) Refine(fn func(T) bool, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) RefineAny(fn func(any) bool, params ...any) *ZodComplex[T]
- func (z *ZodComplex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodComplex[T]) Transform(fn func(complex128, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- type ZodComplexDef
- type ZodComplexInternals
- type ZodDiscriminatedUnion
- func DiscriminatedUnion(disc string, options []any, args ...any) *ZodDiscriminatedUnion[any, any]
- func DiscriminatedUnionPtr(disc string, options []any, args ...any) *ZodDiscriminatedUnion[any, *any]
- func DiscriminatedUnionTyped[T any, R any](disc string, options []any, args ...any) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) CloneFrom(source any)
- func (z *ZodDiscriminatedUnion[T, R]) Default(v T) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) DefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) Describe(desc string) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) Discriminator() string
- func (z *ZodDiscriminatedUnion[T, R]) DiscriminatorMap() map[any]core.ZodSchema
- func (z *ZodDiscriminatedUnion[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodDiscriminatedUnion[T, R]) IsNilable() bool
- func (z *ZodDiscriminatedUnion[T, R]) IsOptional() bool
- func (z *ZodDiscriminatedUnion[T, R]) Meta(meta core.GlobalMeta) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodDiscriminatedUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodDiscriminatedUnion[T, R]) Nilable() *ZodDiscriminatedUnion[T, *T]
- func (z *ZodDiscriminatedUnion[T, R]) Nullish() *ZodDiscriminatedUnion[T, *T]
- func (z *ZodDiscriminatedUnion[T, R]) Optional() *ZodDiscriminatedUnion[T, *T]
- func (z *ZodDiscriminatedUnion[T, R]) Options() []core.ZodSchema
- func (z *ZodDiscriminatedUnion[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodDiscriminatedUnion[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodDiscriminatedUnion[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodDiscriminatedUnion[T, R]) Prefault(v T) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) PrefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) Refine(fn func(R) bool, params ...any) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodDiscriminatedUnion[T, R]
- func (z *ZodDiscriminatedUnion[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodDiscriminatedUnion[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- type ZodDiscriminatedUnionDef
- type ZodDiscriminatedUnionInternals
- type ZodE164
- func (z *ZodE164[T]) Default(v string) *ZodE164[T]
- func (z *ZodE164[T]) DefaultFunc(fn func() string) *ZodE164[T]
- func (z *ZodE164[T]) Describe(description string) *ZodE164[T]
- func (z *ZodE164[T]) Meta(meta core.GlobalMeta) *ZodE164[T]
- func (z *ZodE164[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodE164[T]) Nilable() *ZodE164[*string]
- func (z *ZodE164[T]) Nullish() *ZodE164[*string]
- func (z *ZodE164[T]) Optional() *ZodE164[*string]
- func (z *ZodE164[T]) Prefault(v string) *ZodE164[T]
- func (z *ZodE164[T]) PrefaultFunc(fn func() string) *ZodE164[T]
- func (z *ZodE164[T]) RefineAny(fn func(any) bool, params ...any) *ZodE164[T]
- func (z *ZodE164[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodEmail
- func (z *ZodEmail[T]) Browser(params ...any) *ZodEmail[T]
- func (z *ZodEmail[T]) Default(v string) *ZodEmail[T]
- func (z *ZodEmail[T]) DefaultFunc(fn func() string) *ZodEmail[T]
- func (z *ZodEmail[T]) Describe(description string) *ZodEmail[T]
- func (z *ZodEmail[T]) HTML5(params ...any) *ZodEmail[T]
- func (z *ZodEmail[T]) Meta(meta core.GlobalMeta) *ZodEmail[T]
- func (z *ZodEmail[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodEmail[T]) Nilable() *ZodEmail[*string]
- func (z *ZodEmail[T]) Nullish() *ZodEmail[*string]
- func (z *ZodEmail[T]) Optional() *ZodEmail[*string]
- func (z *ZodEmail[T]) Prefault(v string) *ZodEmail[T]
- func (z *ZodEmail[T]) PrefaultFunc(fn func() string) *ZodEmail[T]
- func (z *ZodEmail[T]) RFC5322(params ...any) *ZodEmail[T]
- func (z *ZodEmail[T]) RefineAny(fn func(any) bool, params ...any) *ZodEmail[T]
- func (z *ZodEmail[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodEmail[T]) Unicode(params ...any) *ZodEmail[T]
- type ZodEmoji
- func (z *ZodEmoji[T]) Default(v string) *ZodEmoji[T]
- func (z *ZodEmoji[T]) DefaultFunc(fn func() string) *ZodEmoji[T]
- func (z *ZodEmoji[T]) Describe(description string) *ZodEmoji[T]
- func (z *ZodEmoji[T]) Meta(meta core.GlobalMeta) *ZodEmoji[T]
- func (z *ZodEmoji[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodEmoji[T]) Nilable() *ZodEmoji[*string]
- func (z *ZodEmoji[T]) Nullish() *ZodEmoji[*string]
- func (z *ZodEmoji[T]) Optional() *ZodEmoji[*string]
- func (z *ZodEmoji[T]) Prefault(v string) *ZodEmoji[T]
- func (z *ZodEmoji[T]) PrefaultFunc(fn func() string) *ZodEmoji[T]
- func (z *ZodEmoji[T]) RefineAny(fn func(any) bool, params ...any) *ZodEmoji[T]
- func (z *ZodEmoji[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodEnum
- func Enum[T comparable](values ...T) *ZodEnum[T, T]
- func EnumMap[T comparable](entries map[string]T, params ...any) *ZodEnum[T, T]
- func EnumMapPtr[T comparable](entries map[string]T, params ...any) *ZodEnum[T, *T]
- func EnumMapTyped[T comparable, R any](entries map[string]T, args ...any) *ZodEnum[T, R]
- func EnumPtr[T comparable](values ...T) *ZodEnum[T, *T]
- func EnumSlice[T comparable](values []T) *ZodEnum[T, T]
- func EnumSlicePtr[T comparable](values []T) *ZodEnum[T, *T]
- func (z *ZodEnum[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodEnum[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) CloneFrom(source any)
- func (z *ZodEnum[T, R]) Default(v T) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) DefaultFunc(fn func() T) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Describe(desc string) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Enum() map[string]T
- func (z *ZodEnum[T, R]) ExactOptional() *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Exclude(keys []string, params ...any) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Extract(keys []string, params ...any) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodEnum[T, R]) IsNilable() bool
- func (z *ZodEnum[T, R]) IsOptional() bool
- func (z *ZodEnum[T, R]) Meta(meta core.GlobalMeta) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodEnum[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodEnum[T, R]) Nilable() *ZodEnum[T, *T]
- func (z *ZodEnum[T, R]) NonOptional() *ZodEnum[T, T]
- func (z *ZodEnum[T, R]) Nullish() *ZodEnum[T, *T]
- func (z *ZodEnum[T, R]) Optional() *ZodEnum[T, *T]
- func (z *ZodEnum[T, R]) Options() []T
- func (z *ZodEnum[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodEnum[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodEnum[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodEnum[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodEnum[T, R]) Prefault(v T) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) PrefaultFunc(fn func() T) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) Refine(fn func(R) bool, params ...any) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodEnum[T, R]
- func (z *ZodEnum[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodEnum[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodEnum[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodEnum[T, R]
- type ZodEnumDef
- type ZodEnumInternals
- type ZodFile
- func (z *ZodFile[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodFile[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) CloneFrom(source any)
- func (z *ZodFile[T, R]) Default(v T) *ZodFile[T, R]
- func (z *ZodFile[T, R]) DefaultFunc(fn func() T) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Describe(desc string) *ZodFile[T, R]
- func (z *ZodFile[T, R]) ExactOptional() *ZodFile[T, R]
- func (z *ZodFile[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodFile[T, R]) IsNilable() bool
- func (z *ZodFile[T, R]) IsOptional() bool
- func (z *ZodFile[T, R]) Max(maximum int64, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Meta(meta core.GlobalMeta) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Mime(mimeTypes []string, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Min(minimum int64, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodFile[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodFile[T, R]) Nilable() *ZodFile[T, *T]
- func (z *ZodFile[T, R]) Nullish() *ZodFile[T, *T]
- func (z *ZodFile[T, R]) Optional() *ZodFile[T, *T]
- func (z *ZodFile[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodFile[T, R]) Overwrite(transform func(R) R, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodFile[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodFile[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodFile[T, R]) Prefault(v T) *ZodFile[T, R]
- func (z *ZodFile[T, R]) PrefaultFunc(fn func() T) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Refine(fn func(R) bool, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) Size(expected int64, params ...any) *ZodFile[T, R]
- func (z *ZodFile[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodFile[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodFile[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFile[T, R]
- type ZodFileDef
- type ZodFileInternals
- type ZodFloat
- type ZodFloatDef
- type ZodFloatInternals
- type ZodFloatTyped
- func CoercedFloat[T FloatConstraint](params ...any) *ZodFloatTyped[T, T]
- func CoercedFloat32(params ...any) *ZodFloatTyped[float32, float32]
- func CoercedFloat32Ptr(params ...any) *ZodFloatTyped[float32, *float32]
- func CoercedFloat64(params ...any) *ZodFloatTyped[float64, float64]
- func CoercedFloat64Ptr(params ...any) *ZodFloatTyped[float64, *float64]
- func CoercedFloatPtr(params ...any) *ZodFloatTyped[float64, *float64]
- func CoercedNumber(params ...any) *ZodFloatTyped[float64, float64]
- func CoercedNumberPtr(params ...any) *ZodFloatTyped[float64, *float64]
- func Float(params ...any) *ZodFloatTyped[float64, float64]
- func Float32(params ...any) *ZodFloatTyped[float32, float32]
- func Float32Ptr(params ...any) *ZodFloatTyped[float32, *float32]
- func Float64(params ...any) *ZodFloatTyped[float64, float64]
- func Float64Ptr(params ...any) *ZodFloatTyped[float64, *float64]
- func FloatPtr(params ...any) *ZodFloatTyped[float64, *float64]
- func FloatTyped[T FloatConstraint](params ...any) *ZodFloatTyped[T, T]
- func Number(params ...any) *ZodFloatTyped[float64, float64]
- func NumberPtr(params ...any) *ZodFloatTyped[float64, *float64]
- func (z *ZodFloatTyped[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodFloatTyped[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) CloneFrom(source any)
- func (z *ZodFloatTyped[T, R]) Coerce(input any) (any, bool)
- func (z *ZodFloatTyped[T, R]) Default(v float64) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) DefaultFunc(fn func() float64) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Describe(description string) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) ExactOptional() *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Finite(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Gt(value float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Gte(value float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Int(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodFloatTyped[T, R]) IsNilable() bool
- func (z *ZodFloatTyped[T, R]) IsOptional() bool
- func (z *ZodFloatTyped[T, R]) Lt(value float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Lte(value float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Max(maximum float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Meta(meta core.GlobalMeta) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Min(minimum float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) MultipleOf(value float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodFloatTyped[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodFloatTyped[T, R]) Negative(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Nilable() *ZodFloatTyped[T, *T]
- func (z *ZodFloatTyped[T, R]) NonNegative(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) NonOptional() *ZodFloatTyped[T, T]
- func (z *ZodFloatTyped[T, R]) NonPositive(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Nullish() *ZodFloatTyped[T, *T]
- func (z *ZodFloatTyped[T, R]) Optional() *ZodFloatTyped[T, *T]
- func (z *ZodFloatTyped[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodFloatTyped[T, R]) Overwrite(transform func(T) T, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodFloatTyped[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodFloatTyped[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodFloatTyped[T, R]) Positive(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Prefault(v float64) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) PrefaultFunc(fn func() float64) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Refine(fn func(T) bool, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Safe(params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) Step(step float64, params ...any) *ZodFloatTyped[T, R]
- func (z *ZodFloatTyped[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodFloatTyped[T, R]) Transform(fn func(float64, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodFloatTyped[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFloatTyped[T, R]
- type ZodFunction
- func (z *ZodFunction[T]) CloneFrom(source any)
- func (z *ZodFunction[T]) Default(v any) *ZodFunction[T]
- func (z *ZodFunction[T]) DefaultFunc(fn func() any) *ZodFunction[T]
- func (z *ZodFunction[T]) Describe(description string) *ZodFunction[T]
- func (z *ZodFunction[T]) Implement(fn any) (any, error)
- func (z *ZodFunction[T]) Input(schema core.ZodType[any]) *ZodFunction[T]
- func (z *ZodFunction[T]) Internals() *core.ZodTypeInternals
- func (z *ZodFunction[T]) IsNilable() bool
- func (z *ZodFunction[T]) IsOptional() bool
- func (z *ZodFunction[T]) Meta(meta core.GlobalMeta) *ZodFunction[T]
- func (z *ZodFunction[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodFunction[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodFunction[T]) Nilable() *ZodFunction[*any]
- func (z *ZodFunction[T]) Nullish() *ZodFunction[*any]
- func (z *ZodFunction[T]) Optional() *ZodFunction[*any]
- func (z *ZodFunction[T]) Output(schema core.ZodType[any]) *ZodFunction[T]
- func (z *ZodFunction[T]) Overwrite(transform func(T) T, params ...any) *ZodFunction[T]
- func (z *ZodFunction[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodFunction[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodFunction[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodFunction[T]) Prefault(v any) *ZodFunction[T]
- func (z *ZodFunction[T]) PrefaultFunc(fn func() any) *ZodFunction[T]
- func (z *ZodFunction[T]) Refine(fn func(T) bool, params ...any) *ZodFunction[T]
- func (z *ZodFunction[T]) RefineAny(fn func(any) bool, params ...any) *ZodFunction[T]
- func (z *ZodFunction[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodFunction[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- type ZodFunctionDef
- type ZodFunctionInternals
- type ZodGUID
- func (z *ZodGUID[T]) Default(v string) *ZodGUID[T]
- func (z *ZodGUID[T]) DefaultFunc(fn func() string) *ZodGUID[T]
- func (z *ZodGUID[T]) Describe(description string) *ZodGUID[T]
- func (z *ZodGUID[T]) Meta(meta core.GlobalMeta) *ZodGUID[T]
- func (z *ZodGUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodGUID[T]) Nilable() *ZodGUID[*string]
- func (z *ZodGUID[T]) Nullish() *ZodGUID[*string]
- func (z *ZodGUID[T]) Optional() *ZodGUID[*string]
- func (z *ZodGUID[T]) Prefault(v string) *ZodGUID[T]
- func (z *ZodGUID[T]) PrefaultFunc(fn func() string) *ZodGUID[T]
- func (z *ZodGUID[T]) RefineAny(fn func(any) bool, params ...any) *ZodGUID[T]
- func (z *ZodGUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodHex
- func (z *ZodHex[T]) Default(v string) *ZodHex[T]
- func (z *ZodHex[T]) DefaultFunc(fn func() string) *ZodHex[T]
- func (z *ZodHex[T]) Describe(description string) *ZodHex[T]
- func (z *ZodHex[T]) Meta(meta core.GlobalMeta) *ZodHex[T]
- func (z *ZodHex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodHex[T]) Nilable() *ZodHex[*string]
- func (z *ZodHex[T]) Nullish() *ZodHex[*string]
- func (z *ZodHex[T]) Optional() *ZodHex[*string]
- func (z *ZodHex[T]) Prefault(v string) *ZodHex[T]
- func (z *ZodHex[T]) PrefaultFunc(fn func() string) *ZodHex[T]
- func (z *ZodHex[T]) RefineAny(fn func(any) bool, params ...any) *ZodHex[T]
- func (z *ZodHex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodHostname
- func (z *ZodHostname[T]) Default(v string) *ZodHostname[T]
- func (z *ZodHostname[T]) DefaultFunc(fn func() string) *ZodHostname[T]
- func (z *ZodHostname[T]) Describe(description string) *ZodHostname[T]
- func (z *ZodHostname[T]) Meta(meta core.GlobalMeta) *ZodHostname[T]
- func (z *ZodHostname[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodHostname[T]) Nilable() *ZodHostname[*string]
- func (z *ZodHostname[T]) Nullish() *ZodHostname[*string]
- func (z *ZodHostname[T]) Optional() *ZodHostname[*string]
- func (z *ZodHostname[T]) Prefault(v string) *ZodHostname[T]
- func (z *ZodHostname[T]) PrefaultFunc(fn func() string) *ZodHostname[T]
- func (z *ZodHostname[T]) RefineAny(fn func(any) bool, params ...any) *ZodHostname[T]
- func (z *ZodHostname[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodIPv4
- func (z *ZodIPv4[T]) Default(v string) *ZodIPv4[T]
- func (z *ZodIPv4[T]) DefaultFunc(fn func() string) *ZodIPv4[T]
- func (z *ZodIPv4[T]) Describe(description string) *ZodIPv4[T]
- func (z *ZodIPv4[T]) Meta(meta core.GlobalMeta) *ZodIPv4[T]
- func (z *ZodIPv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodIPv4[T]) Nilable() *ZodIPv4[*string]
- func (z *ZodIPv4[T]) Nullish() *ZodIPv4[*string]
- func (z *ZodIPv4[T]) Optional() *ZodIPv4[*string]
- func (z *ZodIPv4[T]) Prefault(v string) *ZodIPv4[T]
- func (z *ZodIPv4[T]) PrefaultFunc(fn func() string) *ZodIPv4[T]
- func (z *ZodIPv4[T]) RefineAny(fn func(any) bool, params ...any) *ZodIPv4[T]
- func (z *ZodIPv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodIPv6
- func (z *ZodIPv6[T]) Default(v string) *ZodIPv6[T]
- func (z *ZodIPv6[T]) DefaultFunc(fn func() string) *ZodIPv6[T]
- func (z *ZodIPv6[T]) Describe(description string) *ZodIPv6[T]
- func (z *ZodIPv6[T]) Meta(meta core.GlobalMeta) *ZodIPv6[T]
- func (z *ZodIPv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodIPv6[T]) Nilable() *ZodIPv6[*string]
- func (z *ZodIPv6[T]) Nullish() *ZodIPv6[*string]
- func (z *ZodIPv6[T]) Optional() *ZodIPv6[*string]
- func (z *ZodIPv6[T]) Prefault(v string) *ZodIPv6[T]
- func (z *ZodIPv6[T]) PrefaultFunc(fn func() string) *ZodIPv6[T]
- func (z *ZodIPv6[T]) RefineAny(fn func(any) bool, params ...any) *ZodIPv6[T]
- func (z *ZodIPv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodInteger
- type ZodIntegerDef
- type ZodIntegerInternals
- type ZodIntegerTyped
- func Byte(params ...any) *ZodIntegerTyped[uint8, uint8]
- func BytePtr(params ...any) *ZodIntegerTyped[uint8, *uint8]
- func CoercedInt(params ...any) *ZodIntegerTyped[int, int]
- func CoercedInt8(params ...any) *ZodIntegerTyped[int8, int8]
- func CoercedInt8Ptr(params ...any) *ZodIntegerTyped[int8, *int8]
- func CoercedInt16(params ...any) *ZodIntegerTyped[int16, int16]
- func CoercedInt16Ptr(params ...any) *ZodIntegerTyped[int16, *int16]
- func CoercedInt32(params ...any) *ZodIntegerTyped[int32, int32]
- func CoercedInt32Ptr(params ...any) *ZodIntegerTyped[int32, *int32]
- func CoercedInt64(params ...any) *ZodIntegerTyped[int64, int64]
- func CoercedInt64Ptr(params ...any) *ZodIntegerTyped[int64, *int64]
- func CoercedIntPtr(params ...any) *ZodIntegerTyped[int, *int]
- func CoercedInteger(params ...any) *ZodIntegerTyped[int64, int64]
- func CoercedIntegerPtr(params ...any) *ZodIntegerTyped[int64, *int64]
- func CoercedUint(params ...any) *ZodIntegerTyped[uint, uint]
- func CoercedUint8(params ...any) *ZodIntegerTyped[uint8, uint8]
- func CoercedUint8Ptr(params ...any) *ZodIntegerTyped[uint8, *uint8]
- func CoercedUint16(params ...any) *ZodIntegerTyped[uint16, uint16]
- func CoercedUint16Ptr(params ...any) *ZodIntegerTyped[uint16, *uint16]
- func CoercedUint32(params ...any) *ZodIntegerTyped[uint32, uint32]
- func CoercedUint32Ptr(params ...any) *ZodIntegerTyped[uint32, *uint32]
- func CoercedUint64(params ...any) *ZodIntegerTyped[uint64, uint64]
- func CoercedUint64Ptr(params ...any) *ZodIntegerTyped[uint64, *uint64]
- func CoercedUintPtr(params ...any) *ZodIntegerTyped[uint, *uint]
- func Int(params ...any) *ZodIntegerTyped[int, int]
- func Int8(params ...any) *ZodIntegerTyped[int8, int8]
- func Int8Ptr(params ...any) *ZodIntegerTyped[int8, *int8]
- func Int16(params ...any) *ZodIntegerTyped[int16, int16]
- func Int16Ptr(params ...any) *ZodIntegerTyped[int16, *int16]
- func Int32(params ...any) *ZodIntegerTyped[int32, int32]
- func Int32Ptr(params ...any) *ZodIntegerTyped[int32, *int32]
- func Int64(params ...any) *ZodIntegerTyped[int64, int64]
- func Int64Ptr(params ...any) *ZodIntegerTyped[int64, *int64]
- func IntPtr(params ...any) *ZodIntegerTyped[int, *int]
- func IntegerTyped[T IntegerConstraint](params ...any) *ZodIntegerTyped[T, T]
- func Rune(params ...any) *ZodIntegerTyped[int32, int32]
- func RunePtr(params ...any) *ZodIntegerTyped[int32, *int32]
- func Uint(params ...any) *ZodIntegerTyped[uint, uint]
- func Uint8(params ...any) *ZodIntegerTyped[uint8, uint8]
- func Uint8Ptr(params ...any) *ZodIntegerTyped[uint8, *uint8]
- func Uint16(params ...any) *ZodIntegerTyped[uint16, uint16]
- func Uint16Ptr(params ...any) *ZodIntegerTyped[uint16, *uint16]
- func Uint32(params ...any) *ZodIntegerTyped[uint32, uint32]
- func Uint32Ptr(params ...any) *ZodIntegerTyped[uint32, *uint32]
- func Uint64(params ...any) *ZodIntegerTyped[uint64, uint64]
- func Uint64Ptr(params ...any) *ZodIntegerTyped[uint64, *uint64]
- func UintPtr(params ...any) *ZodIntegerTyped[uint, *uint]
- func (z *ZodIntegerTyped[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodIntegerTyped[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) CloneFrom(source any)
- func (z *ZodIntegerTyped[T, R]) Coerce(input any) (any, bool)
- func (z *ZodIntegerTyped[T, R]) Default(v int64) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) DefaultFunc(fn func() int64) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Describe(description string) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) ExactOptional() *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Gt(value int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Gte(value int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodIntegerTyped[T, R]) IsNilable() bool
- func (z *ZodIntegerTyped[T, R]) IsOptional() bool
- func (z *ZodIntegerTyped[T, R]) Lt(value int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Lte(value int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Max(maximum int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Meta(meta core.GlobalMeta) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Min(minimum int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) MultipleOf(value int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodIntegerTyped[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodIntegerTyped[T, R]) Negative(params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Nilable() *ZodIntegerTyped[T, *T]
- func (z *ZodIntegerTyped[T, R]) NonNegative(params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) NonOptional() *ZodIntegerTyped[T, T]
- func (z *ZodIntegerTyped[T, R]) NonPositive(params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Nullish() *ZodIntegerTyped[T, *T]
- func (z *ZodIntegerTyped[T, R]) Optional() *ZodIntegerTyped[T, *T]
- func (z *ZodIntegerTyped[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodIntegerTyped[T, R]) Overwrite(transform func(T) T, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodIntegerTyped[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodIntegerTyped[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodIntegerTyped[T, R]) Positive(params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Prefault(v int64) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) PrefaultFunc(fn func() R) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Refine(fn func(T) bool, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Safe(params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) Step(step int64, params ...any) *ZodIntegerTyped[T, R]
- func (z *ZodIntegerTyped[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodIntegerTyped[T, R]) Transform(fn func(int64, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodIntegerTyped[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodIntegerTyped[T, R]
- type ZodIntersection
- func (i *ZodIntersection[T, R]) And(other any) *ZodIntersection[any, any]
- func (i *ZodIntersection[T, R]) CloneFrom(source any)
- func (i *ZodIntersection[T, R]) Default(v T) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) DefaultFunc(fn func() T) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) Describe(description string) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) Internals() *core.ZodTypeInternals
- func (i *ZodIntersection[T, R]) IsNilable() bool
- func (i *ZodIntersection[T, R]) IsOptional() bool
- func (i *ZodIntersection[T, R]) Left() core.ZodSchema
- func (i *ZodIntersection[T, R]) Meta(meta core.GlobalMeta) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (i *ZodIntersection[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (i *ZodIntersection[T, R]) Nilable() *ZodIntersection[T, *T]
- func (i *ZodIntersection[T, R]) NonOptional() *ZodIntersection[T, T]
- func (i *ZodIntersection[T, R]) Nullish() *ZodIntersection[T, *T]
- func (i *ZodIntersection[T, R]) Optional() *ZodIntersection[T, *T]
- func (i *ZodIntersection[T, R]) Or(other any) *ZodUnion[any, any]
- func (i *ZodIntersection[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (i *ZodIntersection[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (i *ZodIntersection[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (i *ZodIntersection[T, R]) Prefault(v T) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) PrefaultFunc(fn func() T) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) Refine(fn func(R) bool, params ...any) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodIntersection[T, R]
- func (i *ZodIntersection[T, R]) Right() core.ZodSchema
- func (i *ZodIntersection[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (i *ZodIntersection[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- type ZodIntersectionDef
- type ZodIntersectionInternals
- type ZodIso
- func Iso(params ...any) *ZodIso[string]
- func IsoDate(params ...any) *ZodIso[string]
- func IsoDatePtr(params ...any) *ZodIso[*string]
- func IsoDateTime(params ...any) *ZodIso[string]
- func IsoDateTimePtr(params ...any) *ZodIso[*string]
- func IsoDateTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]
- func IsoDateTyped[T IsoConstraint](params ...any) *ZodIso[T]
- func IsoDuration(params ...any) *ZodIso[string]
- func IsoDurationPtr(params ...any) *ZodIso[*string]
- func IsoDurationTyped[T IsoConstraint](params ...any) *ZodIso[T]
- func IsoPtr(params ...any) *ZodIso[*string]
- func IsoTime(params ...any) *ZodIso[string]
- func IsoTimePtr(params ...any) *ZodIso[*string]
- func IsoTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]
- func IsoTyped[T IsoConstraint](params ...any) *ZodIso[T]
- func (z *ZodIso[T]) Date(params ...any) *ZodIso[T]
- func (z *ZodIso[T]) DateTime(opts ...IsoDatetimeOptions) *ZodIso[T]
- func (z *ZodIso[T]) Default(v string) *ZodIso[T]
- func (z *ZodIso[T]) DefaultFunc(fn func() string) *ZodIso[T]
- func (z *ZodIso[T]) Describe(description string) *ZodIso[T]
- func (z *ZodIso[T]) Duration(params ...any) *ZodIso[T]
- func (z *ZodIso[T]) Internals() *core.ZodTypeInternals
- func (z *ZodIso[T]) Max(v string, params ...any) *ZodIso[T]
- func (z *ZodIso[T]) Meta(meta core.GlobalMeta) *ZodIso[T]
- func (z *ZodIso[T]) Min(v string, params ...any) *ZodIso[T]
- func (z *ZodIso[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodIso[T]) Nilable() *ZodIso[*string]
- func (z *ZodIso[T]) Nullish() *ZodIso[*string]
- func (z *ZodIso[T]) Optional() *ZodIso[*string]
- func (z *ZodIso[T]) Prefault(v string) *ZodIso[T]
- func (z *ZodIso[T]) PrefaultFunc(fn func() string) *ZodIso[T]
- func (z *ZodIso[T]) RefineAny(fn func(any) bool, params ...any) *ZodIso[T]
- func (z *ZodIso[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodIso[T]) Time(opts ...IsoTimeOptions) *ZodIso[T]
- type ZodJWT
- func (z *ZodJWT[T]) Default(v string) *ZodJWT[T]
- func (z *ZodJWT[T]) DefaultFunc(fn func() string) *ZodJWT[T]
- func (z *ZodJWT[T]) Describe(description string) *ZodJWT[T]
- func (z *ZodJWT[T]) Meta(meta core.GlobalMeta) *ZodJWT[T]
- func (z *ZodJWT[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodJWT[T]) Nilable() *ZodJWT[*string]
- func (z *ZodJWT[T]) Nullish() *ZodJWT[*string]
- func (z *ZodJWT[T]) Optional() *ZodJWT[*string]
- func (z *ZodJWT[T]) Prefault(v string) *ZodJWT[T]
- func (z *ZodJWT[T]) PrefaultFunc(fn func() string) *ZodJWT[T]
- func (z *ZodJWT[T]) RefineAny(fn func(any) bool, params ...any) *ZodJWT[T]
- func (z *ZodJWT[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodKSUID
- func (z *ZodKSUID[T]) Default(v string) *ZodKSUID[T]
- func (z *ZodKSUID[T]) DefaultFunc(fn func() string) *ZodKSUID[T]
- func (z *ZodKSUID[T]) Describe(description string) *ZodKSUID[T]
- func (z *ZodKSUID[T]) Meta(meta core.GlobalMeta) *ZodKSUID[T]
- func (z *ZodKSUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodKSUID[T]) Nilable() *ZodKSUID[*string]
- func (z *ZodKSUID[T]) Nullish() *ZodKSUID[*string]
- func (z *ZodKSUID[T]) Optional() *ZodKSUID[*string]
- func (z *ZodKSUID[T]) Prefault(v string) *ZodKSUID[T]
- func (z *ZodKSUID[T]) PrefaultFunc(fn func() string) *ZodKSUID[T]
- func (z *ZodKSUID[T]) RefineAny(fn func(any) bool, params ...any) *ZodKSUID[T]
- func (z *ZodKSUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodLazy
- func (z *ZodLazy[T]) CloneFrom(source any)
- func (z *ZodLazy[T]) Coerce(input any) (any, bool)
- func (z *ZodLazy[T]) Default(v any) *ZodLazy[T]
- func (z *ZodLazy[T]) DefaultFunc(fn func() any) *ZodLazy[T]
- func (z *ZodLazy[T]) Describe(description string) *ZodLazy[T]
- func (z *ZodLazy[T]) Internals() *core.ZodTypeInternals
- func (z *ZodLazy[T]) IsNilable() bool
- func (z *ZodLazy[T]) IsOptional() bool
- func (z *ZodLazy[T]) Meta(meta core.GlobalMeta) *ZodLazy[T]
- func (z *ZodLazy[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodLazy[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodLazy[T]) Nilable() *ZodLazy[*any]
- func (z *ZodLazy[T]) NonOptional() *ZodLazy[any]
- func (z *ZodLazy[T]) Nullish() *ZodLazy[*any]
- func (z *ZodLazy[T]) Optional() *ZodLazy[*any]
- func (z *ZodLazy[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodLazy[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodLazy[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodLazy[T]) Prefault(v any) *ZodLazy[T]
- func (z *ZodLazy[T]) PrefaultFunc(fn func() any) *ZodLazy[T]
- func (z *ZodLazy[T]) Refine(fn func(T) bool, params ...any) *ZodLazy[T]
- func (z *ZodLazy[T]) RefineAny(fn func(any) bool, params ...any) *ZodLazy[T]
- func (z *ZodLazy[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodLazy[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- func (z *ZodLazy[T]) Unwrap() core.ZodType[any]
- type ZodLazyDef
- type ZodLazyInternals
- type ZodLazyTyped
- func (z *ZodLazyTyped[S]) Default(v any) *ZodLazyTyped[S]
- func (z *ZodLazyTyped[S]) InnerSchema() S
- func (z *ZodLazyTyped[S]) MustParse(input any, ctx ...*core.ParseContext) any
- func (z *ZodLazyTyped[S]) Nilable() *ZodLazy[*any]
- func (z *ZodLazyTyped[S]) NonOptional() *ZodLazy[any]
- func (z *ZodLazyTyped[S]) Optional() *ZodLazy[*any]
- func (z *ZodLazyTyped[S]) Parse(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodLazyTyped[S]) Refine(fn func(any) bool, params ...any) *ZodLazyTyped[S]
- type ZodLiteral
- func Literal[T comparable](value T, params ...any) *ZodLiteral[T, T]
- func LiteralOf[T comparable](values []T, params ...any) *ZodLiteral[T, T]
- func LiteralPtr[T comparable](value T, params ...any) *ZodLiteral[T, *T]
- func LiteralPtrOf[T comparable](values []T, params ...any) *ZodLiteral[T, *T]
- func LiteralTyped[T comparable, R any](value T, params ...any) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) Contains(v T) bool
- func (z *ZodLiteral[T, R]) Default(v T) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) DefaultFunc(fn func() T) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) Describe(description string) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodLiteral[T, R]) IsNilable() bool
- func (z *ZodLiteral[T, R]) IsOptional() bool
- func (z *ZodLiteral[T, R]) Meta(meta core.GlobalMeta) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodLiteral[T, R]) MustParseAny(input any, ctx ...*core.ParseContext) any
- func (z *ZodLiteral[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodLiteral[T, R]) Nilable() *ZodLiteral[T, *T]
- func (z *ZodLiteral[T, R]) Nullish() *ZodLiteral[T, *T]
- func (z *ZodLiteral[T, R]) Optional() *ZodLiteral[T, *T]
- func (z *ZodLiteral[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodLiteral[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodLiteral[T, R]) Prefault(v T) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) PrefaultFunc(fn func() T) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) Refine(fn func(T) bool, params ...any) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodLiteral[T, R]
- func (z *ZodLiteral[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodLiteral[T, R]) Value() T
- func (z *ZodLiteral[T, R]) Values() []T
- type ZodLiteralDef
- type ZodLiteralInternals
- type ZodMAC
- func (z *ZodMAC[T]) Default(v string) *ZodMAC[T]
- func (z *ZodMAC[T]) DefaultFunc(fn func() string) *ZodMAC[T]
- func (z *ZodMAC[T]) Describe(description string) *ZodMAC[T]
- func (z *ZodMAC[T]) Meta(meta core.GlobalMeta) *ZodMAC[T]
- func (z *ZodMAC[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodMAC[T]) Nilable() *ZodMAC[*string]
- func (z *ZodMAC[T]) Nullish() *ZodMAC[*string]
- func (z *ZodMAC[T]) Optional() *ZodMAC[*string]
- func (z *ZodMAC[T]) Prefault(v string) *ZodMAC[T]
- func (z *ZodMAC[T]) PrefaultFunc(fn func() string) *ZodMAC[T]
- func (z *ZodMAC[T]) RefineAny(fn func(any) bool, params ...any) *ZodMAC[T]
- func (z *ZodMAC[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodMap
- func (z *ZodMap[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) CloneFrom(source any)
- func (z *ZodMap[T, R]) Default(v T) *ZodMap[T, R]
- func (z *ZodMap[T, R]) DefaultFunc(fn func() T) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Describe(description string) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodMap[T, R]) IsNilable() bool
- func (z *ZodMap[T, R]) IsOptional() bool
- func (z *ZodMap[T, R]) KeyType() any
- func (z *ZodMap[T, R]) Length(exactLen int, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Max(maxLen int, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Meta(meta core.GlobalMeta) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Min(minLen int, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodMap[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodMap[T, R]) Nilable() *ZodMap[T, *T]
- func (z *ZodMap[T, R]) NonEmpty(params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) NonOptional() *ZodMap[T, T]
- func (z *ZodMap[T, R]) Nullish() *ZodMap[T, *T]
- func (z *ZodMap[T, R]) Optional() *ZodMap[T, *T]
- func (z *ZodMap[T, R]) Overwrite(transform func(R) R, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodMap[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodMap[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodMap[T, R]) Prefault(v T) *ZodMap[T, R]
- func (z *ZodMap[T, R]) PrefaultFunc(fn func() T) *ZodMap[T, R]
- func (z *ZodMap[T, R]) Refine(fn func(R) bool, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodMap[T, R]
- func (z *ZodMap[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodMap[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodMap[T, R]) ValueType() any
- func (z *ZodMap[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodMap[T, R]
- type ZodMapDef
- type ZodMapInternals
- type ZodNanoID
- func (z *ZodNanoID[T]) Default(v string) *ZodNanoID[T]
- func (z *ZodNanoID[T]) DefaultFunc(fn func() string) *ZodNanoID[T]
- func (z *ZodNanoID[T]) Describe(description string) *ZodNanoID[T]
- func (z *ZodNanoID[T]) Meta(meta core.GlobalMeta) *ZodNanoID[T]
- func (z *ZodNanoID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodNanoID[T]) Nilable() *ZodNanoID[*string]
- func (z *ZodNanoID[T]) Nullish() *ZodNanoID[*string]
- func (z *ZodNanoID[T]) Optional() *ZodNanoID[*string]
- func (z *ZodNanoID[T]) Prefault(v string) *ZodNanoID[T]
- func (z *ZodNanoID[T]) PrefaultFunc(fn func() string) *ZodNanoID[T]
- func (z *ZodNanoID[T]) RefineAny(fn func(any) bool, params ...any) *ZodNanoID[T]
- func (z *ZodNanoID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodNever
- func (z *ZodNever[T, R]) CloneFrom(source any)
- func (z *ZodNever[T, R]) Default(v T) *ZodNever[T, R]
- func (z *ZodNever[T, R]) DefaultFunc(fn func() T) *ZodNever[T, R]
- func (z *ZodNever[T, R]) Describe(description string) *ZodNever[T, R]
- func (z *ZodNever[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodNever[T, R]) IsNilable() bool
- func (z *ZodNever[T, R]) IsOptional() bool
- func (z *ZodNever[T, R]) Meta(meta core.GlobalMeta) *ZodNever[T, R]
- func (z *ZodNever[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodNever[T, R]) MustParseAny(input any, ctx ...*core.ParseContext) any
- func (z *ZodNever[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodNever[T, R]) Nilable() *ZodNever[T, *T]
- func (z *ZodNever[T, R]) Nullish() *ZodNever[T, *T]
- func (z *ZodNever[T, R]) Optional() *ZodNever[T, *T]
- func (z *ZodNever[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodNever[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodNever[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodNever[T, R]) Prefault(v T) *ZodNever[T, R]
- func (z *ZodNever[T, R]) PrefaultFunc(fn func() T) *ZodNever[T, R]
- func (z *ZodNever[T, R]) Refine(fn func(R) bool, params ...any) *ZodNever[T, R]
- func (z *ZodNever[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodNever[T, R]
- func (z *ZodNever[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodNever[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodNever[T, R]) Unwrap() *ZodNever[T, R]
- type ZodNeverDef
- type ZodNeverInternals
- type ZodNil
- func (z *ZodNil[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodNil[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodNil[T, R]
- func (z *ZodNil[T, R]) CloneFrom(source any)
- func (z *ZodNil[T, R]) Default(v T) *ZodNil[T, R]
- func (z *ZodNil[T, R]) DefaultFunc(fn func() T) *ZodNil[T, R]
- func (z *ZodNil[T, R]) Describe(desc string) *ZodNil[T, R]
- func (z *ZodNil[T, R]) ExactOptional() *ZodNil[T, R]
- func (z *ZodNil[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodNil[T, R]) IsNilable() bool
- func (z *ZodNil[T, R]) IsOptional() bool
- func (z *ZodNil[T, R]) Meta(meta core.GlobalMeta) *ZodNil[T, R]
- func (z *ZodNil[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodNil[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodNil[T, R]) Nilable() *ZodNil[T, *T]
- func (z *ZodNil[T, R]) NonOptional() *ZodNil[T, T]
- func (z *ZodNil[T, R]) Nullish() *ZodNil[T, *T]
- func (z *ZodNil[T, R]) Optional() *ZodNil[T, *T]
- func (z *ZodNil[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodNil[T, R]) Overwrite(transform func(R) R, params ...any) *ZodNil[T, R]
- func (z *ZodNil[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodNil[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodNil[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodNil[T, R]) Prefault(v T) *ZodNil[T, R]
- func (z *ZodNil[T, R]) PrefaultFunc(fn func() T) *ZodNil[T, R]
- func (z *ZodNil[T, R]) Refine(fn func(R) bool, params ...any) *ZodNil[T, R]
- func (z *ZodNil[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodNil[T, R]
- func (z *ZodNil[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodNil[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodNil[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodNil[T, R]
- type ZodNilDef
- type ZodNilInternals
- type ZodObject
- func LooseObject(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]
- func LooseObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]
- func Object(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]
- func ObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]
- func ObjectTyped[T any, R any](shape core.ObjectSchema, params ...any) *ZodObject[T, R]
- func StrictObject(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, map[string]any]
- func StrictObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]
- func (z *ZodObject[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodObject[T, R]) Catchall() core.ZodSchema
- func (z *ZodObject[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) CloneFrom(source any)
- func (z *ZodObject[T, R]) Default(v T) *ZodObject[T, R]
- func (z *ZodObject[T, R]) DefaultFunc(fn func() T) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Describe(description string) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Extend(augmentation core.ObjectSchema, params ...any) (*ZodObject[T, R], error)
- func (z *ZodObject[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodObject[T, R]) IsNilable() bool
- func (z *ZodObject[T, R]) IsOptional() bool
- func (z *ZodObject[T, R]) Keyof() *ZodEnum[string, string]
- func (z *ZodObject[T, R]) Length(exactLen int, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Max(maxLen int, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Merge(other *ZodObject[T, R], params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Meta(meta core.GlobalMeta) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Min(minLen int, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) MustOmit(keys []string, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodObject[T, R]) MustPick(keys []string, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodObject[T, R]) Nilable() *ZodObject[T, *T]
- func (z *ZodObject[T, R]) NonOptional() *ZodObject[T, T]
- func (z *ZodObject[T, R]) Nullish() *ZodObject[T, *T]
- func (z *ZodObject[T, R]) Omit(keys []string, params ...any) (*ZodObject[T, R], error)
- func (z *ZodObject[T, R]) Optional() *ZodObject[T, *T]
- func (z *ZodObject[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodObject[T, R]) Overwrite(transform func(R) R, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodObject[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodObject[T, R]) Partial(keys ...[]string) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Passthrough() *ZodObject[T, R]
- func (z *ZodObject[T, R]) Pick(keys []string, params ...any) (*ZodObject[T, R], error)
- func (z *ZodObject[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodObject[T, R]) Prefault(v T) *ZodObject[T, R]
- func (z *ZodObject[T, R]) PrefaultFunc(fn func() T) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Property(key string, schema core.ZodSchema, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Refine(fn func(R) bool, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Required(fields ...[]string) *ZodObject[T, R]
- func (z *ZodObject[T, R]) SafeExtend(augmentation core.ObjectSchema, params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) Shape() core.ObjectSchema
- func (z *ZodObject[T, R]) Strict() *ZodObject[T, R]
- func (z *ZodObject[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodObject[T, R]) Strip() *ZodObject[T, R]
- func (z *ZodObject[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodObject[T, R]) UnknownKeys() ObjectMode
- func (z *ZodObject[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodObject[T, R]
- func (z *ZodObject[T, R]) WithCatchall(catchallSchema core.ZodSchema) *ZodObject[T, R]
- func (z *ZodObject[T, R]) WithFieldNameTag(fieldNameTag string) *ZodObject[T, R]
- type ZodObjectDef
- type ZodObjectInternals
- type ZodRecord
- func LooseRecord(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]
- func LooseRecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]
- func PartialRecord(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]
- func PartialRecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]
- func Record(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]
- func RecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]
- func RecordTyped[T any, R any](keySchema, valueSchema any, paramArgs ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) CloneFrom(source any)
- func (z *ZodRecord[T, R]) Default(v T) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) DefaultFunc(fn func() T) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Describe(description string) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodRecord[T, R]) IsLoose() bool
- func (z *ZodRecord[T, R]) IsNilable() bool
- func (z *ZodRecord[T, R]) IsOptional() bool
- func (z *ZodRecord[T, R]) KeyType() any
- func (z *ZodRecord[T, R]) Length(exactLen int, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Max(maxLen int, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Meta(meta core.GlobalMeta) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Min(minLen int, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodRecord[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodRecord[T, R]) Nilable() *ZodRecord[T, *T]
- func (z *ZodRecord[T, R]) NonOptional() *ZodRecord[T, T]
- func (z *ZodRecord[T, R]) Nullish() *ZodRecord[T, *T]
- func (z *ZodRecord[T, R]) Optional() *ZodRecord[T, *T]
- func (z *ZodRecord[T, R]) Overwrite(transform func(R) R, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodRecord[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodRecord[T, R]) Partial() *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodRecord[T, R]) Prefault(v T) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) PrefaultFunc(fn func() T) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) Refine(fn func(R) bool, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodRecord[T, R]
- func (z *ZodRecord[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodRecord[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodRecord[T, R]) ValueType() any
- func (z *ZodRecord[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodRecord[T, R]
- type ZodRecordDef
- type ZodRecordInternals
- type ZodSchemaType
- type ZodSet
- func (z *ZodSet[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodSet[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) CloneFrom(source any)
- func (z *ZodSet[T, R]) Default(v map[T]struct{}) *ZodSet[T, R]
- func (z *ZodSet[T, R]) DefaultFunc(fn func() map[T]struct{}) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Describe(description string) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodSet[T, R]) IsNilable() bool
- func (z *ZodSet[T, R]) IsOptional() bool
- func (z *ZodSet[T, R]) Length(exactLen int, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Max(maxLen int, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Meta(meta core.GlobalMeta) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Min(minLen int, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodSet[T, R]) MustStrictParse(input map[T]struct{}, ctx ...*core.ParseContext) R
- func (z *ZodSet[T, R]) Nilable() *ZodSet[T, *map[T]struct{}]
- func (z *ZodSet[T, R]) NonEmpty(params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) NonOptional() *ZodSet[T, map[T]struct{}]
- func (z *ZodSet[T, R]) Nullish() *ZodSet[T, *map[T]struct{}]
- func (z *ZodSet[T, R]) Optional() *ZodSet[T, *map[T]struct{}]
- func (z *ZodSet[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodSet[T, R]) Overwrite(transform func(R) R, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodSet[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodSet[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodSet[T, R]) Prefault(v map[T]struct{}) *ZodSet[T, R]
- func (z *ZodSet[T, R]) PrefaultFunc(fn func() map[T]struct{}) *ZodSet[T, R]
- func (z *ZodSet[T, R]) Refine(fn func(R) bool, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodSet[T, R]
- func (z *ZodSet[T, R]) StrictParse(input map[T]struct{}, ctx ...*core.ParseContext) (R, error)
- func (z *ZodSet[T, R]) Transform(fn func(R, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodSet[T, R]) ValueType() any
- func (z *ZodSet[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodSet[T, R]
- type ZodSetDef
- type ZodSetInternals
- type ZodSlice
- func (z *ZodSlice[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodSlice[T, R]) Check(fn func(R, *core.ParsePayload), params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) CloneFrom(source any)
- func (z *ZodSlice[T, R]) Default(v []T) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) DefaultFunc(fn func() []T) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Describe(description string) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Element() core.ZodSchema
- func (z *ZodSlice[T, R]) ExactOptional() *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodSlice[T, R]) IsNilable() bool
- func (z *ZodSlice[T, R]) IsOptional() bool
- func (z *ZodSlice[T, R]) Length(n int, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Max(n int, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Meta(meta core.GlobalMeta) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Min(n int, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodSlice[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodSlice[T, R]) Nilable() *ZodSlice[T, *[]T]
- func (z *ZodSlice[T, R]) NonEmpty(params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) NonOptional() *ZodSlice[T, []T]
- func (z *ZodSlice[T, R]) Nullish() *ZodSlice[T, *[]T]
- func (z *ZodSlice[T, R]) Optional() *ZodSlice[T, *[]T]
- func (z *ZodSlice[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodSlice[T, R]) Overwrite(fn func(R) R, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodSlice[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodSlice[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodSlice[T, R]) Prefault(v []T) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) PrefaultFunc(fn func() []T) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) Refine(fn func(R) bool, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodSlice[T, R]
- func (z *ZodSlice[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodSlice[T, R]) Transform(fn func(R, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodSlice[T, R]) With(fn func(R, *core.ParsePayload), params ...any) *ZodSlice[T, R]
- type ZodSliceDef
- type ZodSliceInternals
- type ZodString
- func (z *ZodString[T]) And(other any) *ZodIntersection[any, any]
- func (z *ZodString[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodString[T]
- func (z *ZodString[T]) CloneFrom(source any)
- func (z *ZodString[T]) Coerce(input any) (any, bool)
- func (z *ZodString[T]) Default(v string) *ZodString[T]
- func (z *ZodString[T]) DefaultFunc(fn func() string) *ZodString[T]
- func (z *ZodString[T]) Describe(description string) *ZodString[T]
- func (z *ZodString[T]) Email(params ...any) *ZodString[T]
- func (z *ZodString[T]) EndsWith(suffix string, params ...any) *ZodString[T]
- func (z *ZodString[T]) ExactOptional() *ZodString[T]
- func (z *ZodString[T]) Includes(substring string, params ...any) *ZodString[T]
- func (z *ZodString[T]) Internals() *core.ZodTypeInternals
- func (z *ZodString[T]) IsNilable() bool
- func (z *ZodString[T]) IsOptional() bool
- func (z *ZodString[T]) JSON(params ...any) *ZodString[T]
- func (z *ZodString[T]) JWT(params ...any) *ZodString[T]
- func (z *ZodString[T]) Length(length int, params ...any) *ZodString[T]
- func (z *ZodString[T]) Lowercase(params ...any) *ZodString[T]
- func (z *ZodString[T]) MAC(params ...any) *ZodString[T]
- func (z *ZodString[T]) Max(maxLen int, params ...any) *ZodString[T]
- func (z *ZodString[T]) Meta(meta core.GlobalMeta) *ZodString[T]
- func (z *ZodString[T]) Min(minLen int, params ...any) *ZodString[T]
- func (z *ZodString[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodString[T]) MustParseAny(input any, ctx ...*core.ParseContext) any
- func (z *ZodString[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodString[T]) Nilable() *ZodString[*string]
- func (z *ZodString[T]) NonOptional() *ZodString[string]
- func (z *ZodString[T]) Normalize(form ...string) *ZodString[T]
- func (z *ZodString[T]) Nullish() *ZodString[*string]
- func (z *ZodString[T]) Optional() *ZodString[*string]
- func (z *ZodString[T]) Or(other any) *ZodUnion[any, any]
- func (z *ZodString[T]) Overwrite(fn func(T) T, params ...any) *ZodString[T]
- func (z *ZodString[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodString[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodString[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodString[T]) Prefault(v string) *ZodString[T]
- func (z *ZodString[T]) PrefaultFunc(fn func() string) *ZodString[T]
- func (z *ZodString[T]) Refine(fn func(T) bool, params ...any) *ZodString[T]
- func (z *ZodString[T]) RefineAny(fn func(any) bool, params ...any) *ZodString[T]
- func (z *ZodString[T]) Regex(pattern *regexp.Regexp, params ...any) *ZodString[T]
- func (z *ZodString[T]) RegexString(pattern string, params ...any) *ZodString[T]
- func (z *ZodString[T]) Slugify(params ...any) *ZodString[T]
- func (z *ZodString[T]) StartsWith(prefix string, params ...any) *ZodString[T]
- func (z *ZodString[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodString[T]) ToLowerCase(params ...any) *ZodString[T]
- func (z *ZodString[T]) ToUpperCase(params ...any) *ZodString[T]
- func (z *ZodString[T]) Transform(fn func(string, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- func (z *ZodString[T]) Trim(params ...any) *ZodString[T]
- func (z *ZodString[T]) Uppercase(params ...any) *ZodString[T]
- func (z *ZodString[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodString[T]
- type ZodStringBool
- func CoercedStringBool(params ...any) *ZodStringBool[bool]
- func CoercedStringBoolPtr(params ...any) *ZodStringBool[*bool]
- func StringBool(params ...any) *ZodStringBool[bool]
- func StringBoolPtr(params ...any) *ZodStringBool[*bool]
- func StringBoolTyped[T StringBoolConstraint](params ...any) *ZodStringBool[T]
- func (z *ZodStringBool[T]) And(other any) *ZodIntersection[any, any]
- func (z *ZodStringBool[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodStringBool[T]
- func (z *ZodStringBool[T]) CloneFrom(source any)
- func (z *ZodStringBool[T]) Coerce(input any) (any, bool)
- func (z *ZodStringBool[T]) Default(v bool) *ZodStringBool[T]
- func (z *ZodStringBool[T]) DefaultFunc(fn func() bool) *ZodStringBool[T]
- func (z *ZodStringBool[T]) Describe(desc string) *ZodStringBool[T]
- func (z *ZodStringBool[T]) ExactOptional() *ZodStringBool[T]
- func (z *ZodStringBool[T]) Internals() *core.ZodTypeInternals
- func (z *ZodStringBool[T]) IsNilable() bool
- func (z *ZodStringBool[T]) IsOptional() bool
- func (z *ZodStringBool[T]) Meta(meta core.GlobalMeta) *ZodStringBool[T]
- func (z *ZodStringBool[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodStringBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodStringBool[T]) Nilable() *ZodStringBool[*bool]
- func (z *ZodStringBool[T]) NonOptional() *ZodStringBool[bool]
- func (z *ZodStringBool[T]) Nullish() *ZodStringBool[*bool]
- func (z *ZodStringBool[T]) Optional() *ZodStringBool[*bool]
- func (z *ZodStringBool[T]) Or(other any) *ZodUnion[any, any]
- func (z *ZodStringBool[T]) Overwrite(transform func(T) T, params ...any) *ZodStringBool[T]
- func (z *ZodStringBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodStringBool[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodStringBool[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodStringBool[T]) Prefault(v string) *ZodStringBool[T]
- func (z *ZodStringBool[T]) PrefaultFunc(fn func() string) *ZodStringBool[T]
- func (z *ZodStringBool[T]) Refine(fn func(T) bool, params ...any) *ZodStringBool[T]
- func (z *ZodStringBool[T]) RefineAny(fn func(any) bool, params ...any) *ZodStringBool[T]
- func (z *ZodStringBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodStringBool[T]) Transform(fn func(bool, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- func (z *ZodStringBool[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodStringBool[T]
- type ZodStringBoolDef
- type ZodStringBoolInternals
- type ZodStringDef
- type ZodStringInternals
- type ZodStruct
- func (z *ZodStruct[T, R]) Catchall() core.ZodSchema
- func (z *ZodStruct[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) CloneFrom(source any)
- func (z *ZodStruct[T, R]) Default(v T) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) DefaultFunc(fn func() T) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Describe(description string) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Extend(augmentation core.StructSchema, params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodStruct[T, R]) IsNilable() bool
- func (z *ZodStruct[T, R]) IsOptional() bool
- func (z *ZodStruct[T, R]) Meta(meta core.GlobalMeta) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodStruct[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodStruct[T, R]) Nilable() *ZodStruct[T, *T]
- func (z *ZodStruct[T, R]) NonOptional() *ZodStruct[T, T]
- func (z *ZodStruct[T, R]) Nullish() *ZodStruct[T, *T]
- func (z *ZodStruct[T, R]) Optional() *ZodStruct[T, *T]
- func (z *ZodStruct[T, R]) Overwrite(transform func(R) R, params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodStruct[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodStruct[T, R]) Partial(keys ...[]string) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodStruct[T, R]) Prefault(v T) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) PrefaultFunc(fn func() T) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Refine(fn func(R) bool, params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Required(fields ...[]string) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) Shape() core.StructSchema
- func (z *ZodStruct[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodStruct[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodStruct[T, R]) UnknownKeys() ObjectMode
- func (z *ZodStruct[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodStruct[T, R]
- func (z *ZodStruct[T, R]) WithFieldNameTag(fieldNameTag string) *ZodStruct[T, R]
- type ZodStructDef
- type ZodStructInternals
- type ZodTime
- func (z *ZodTime[T]) And(other any) *ZodIntersection[any, any]
- func (z *ZodTime[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodTime[T]
- func (z *ZodTime[T]) CloneFrom(source any)
- func (z *ZodTime[T]) Coerce(input any) (any, bool)
- func (z *ZodTime[T]) Default(v time.Time) *ZodTime[T]
- func (z *ZodTime[T]) DefaultFunc(fn func() time.Time) *ZodTime[T]
- func (z *ZodTime[T]) Describe(desc string) *ZodTime[T]
- func (z *ZodTime[T]) ExactOptional() *ZodTime[T]
- func (z *ZodTime[T]) Internals() *core.ZodTypeInternals
- func (z *ZodTime[T]) IsNilable() bool
- func (z *ZodTime[T]) IsOptional() bool
- func (z *ZodTime[T]) Meta(meta core.GlobalMeta) *ZodTime[T]
- func (z *ZodTime[T]) MustParse(input any, ctx ...*core.ParseContext) T
- func (z *ZodTime[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodTime[T]) Nilable() *ZodTime[*time.Time]
- func (z *ZodTime[T]) NonOptional() *ZodTime[time.Time]
- func (z *ZodTime[T]) Nullish() *ZodTime[*time.Time]
- func (z *ZodTime[T]) Optional() *ZodTime[*time.Time]
- func (z *ZodTime[T]) Or(other any) *ZodUnion[any, any]
- func (z *ZodTime[T]) Overwrite(transform func(T) T, params ...any) *ZodTime[T]
- func (z *ZodTime[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
- func (z *ZodTime[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodTime[T]) Pipe(target core.ZodType[any]) *core.ZodPipe[T, any]
- func (z *ZodTime[T]) Prefault(v time.Time) *ZodTime[T]
- func (z *ZodTime[T]) PrefaultFunc(fn func() time.Time) *ZodTime[T]
- func (z *ZodTime[T]) Refine(fn func(T) bool, params ...any) *ZodTime[T]
- func (z *ZodTime[T]) RefineAny(fn func(any) bool, params ...any) *ZodTime[T]
- func (z *ZodTime[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- func (z *ZodTime[T]) Transform(fn func(time.Time, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
- func (z *ZodTime[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodTime[T]
- type ZodTimeDef
- type ZodTimeInternals
- type ZodTuple
- func Tuple(items ...core.ZodSchema) *ZodTuple[[]any, []any]
- func TuplePtr(items ...core.ZodSchema) *ZodTuple[[]any, *[]any]
- func TupleTyped[T any, R any](items []core.ZodSchema, rest core.ZodSchema, params ...any) *ZodTuple[T, R]
- func TupleWithRest(items []core.ZodSchema, rest core.ZodSchema, params ...any) *ZodTuple[[]any, []any]
- func (z *ZodTuple[T, R]) Check(check core.ZodCheck) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Default(v []any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Describe(description string) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) ExactOptional() *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodTuple[T, R]) IsNilable() bool
- func (z *ZodTuple[T, R]) IsOptional() bool
- func (z *ZodTuple[T, R]) Items() []core.ZodSchema
- func (z *ZodTuple[T, R]) Length(length int, params ...any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Max(maximum int, params ...any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Meta(meta core.GlobalMeta) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Min(minimum int, params ...any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodTuple[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodTuple[T, R]) Nilable() *ZodTuple[T, *[]any]
- func (z *ZodTuple[T, R]) NonEmpty(params ...any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Nullish() *ZodTuple[T, *[]any]
- func (z *ZodTuple[T, R]) Optional() *ZodTuple[T, *[]any]
- func (z *ZodTuple[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodTuple[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodTuple[T, R]) Refine(fn func([]any) bool, params ...any) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) Rest() core.ZodSchema
- func (z *ZodTuple[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodTuple[T, R]) With(check core.ZodCheck) *ZodTuple[T, R]
- func (z *ZodTuple[T, R]) WithRest(restSchema core.ZodSchema) *ZodTuple[T, R]
- type ZodTupleDef
- type ZodTupleInternals
- type ZodULID
- func (z *ZodULID[T]) Default(v string) *ZodULID[T]
- func (z *ZodULID[T]) DefaultFunc(fn func() string) *ZodULID[T]
- func (z *ZodULID[T]) Describe(description string) *ZodULID[T]
- func (z *ZodULID[T]) Meta(meta core.GlobalMeta) *ZodULID[T]
- func (z *ZodULID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodULID[T]) Nilable() *ZodULID[*string]
- func (z *ZodULID[T]) Nullish() *ZodULID[*string]
- func (z *ZodULID[T]) Optional() *ZodULID[*string]
- func (z *ZodULID[T]) Prefault(v string) *ZodULID[T]
- func (z *ZodULID[T]) PrefaultFunc(fn func() string) *ZodULID[T]
- func (z *ZodULID[T]) RefineAny(fn func(any) bool, params ...any) *ZodULID[T]
- func (z *ZodULID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodURL
- func CoercedURL(params ...any) *ZodURL[string]
- func HTTPURL(params ...any) *ZodURL[string]
- func HTTPURLPtr(params ...any) *ZodURL[*string]
- func HTTPURLTyped[T StringConstraint](params ...any) *ZodURL[T]
- func URL(params ...any) *ZodURL[string]
- func URLPtr(params ...any) *ZodURL[*string]
- func URLTyped[T StringConstraint](params ...any) *ZodURL[T]
- func (z *ZodURL[T]) Default(v string) *ZodURL[T]
- func (z *ZodURL[T]) DefaultFunc(fn func() string) *ZodURL[T]
- func (z *ZodURL[T]) Describe(description string) *ZodURL[T]
- func (z *ZodURL[T]) Meta(meta core.GlobalMeta) *ZodURL[T]
- func (z *ZodURL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodURL[T]) Nilable() *ZodURL[*string]
- func (z *ZodURL[T]) Nullish() *ZodURL[*string]
- func (z *ZodURL[T]) Optional() *ZodURL[*string]
- func (z *ZodURL[T]) Prefault(v string) *ZodURL[T]
- func (z *ZodURL[T]) PrefaultFunc(fn func() string) *ZodURL[T]
- func (z *ZodURL[T]) RefineAny(fn func(any) bool, params ...any) *ZodURL[T]
- func (z *ZodURL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodUUID
- func UUID(params ...any) *ZodUUID[string]
- func UUIDPtr(params ...any) *ZodUUID[*string]
- func UUIDv4(params ...any) *ZodUUID[string]
- func UUIDv4Ptr(params ...any) *ZodUUID[*string]
- func UUIDv6(params ...any) *ZodUUID[string]
- func UUIDv6Ptr(params ...any) *ZodUUID[*string]
- func UUIDv7(params ...any) *ZodUUID[string]
- func UUIDv7Ptr(params ...any) *ZodUUID[*string]
- func (z *ZodUUID[T]) Default(v string) *ZodUUID[T]
- func (z *ZodUUID[T]) DefaultFunc(fn func() string) *ZodUUID[T]
- func (z *ZodUUID[T]) Describe(description string) *ZodUUID[T]
- func (z *ZodUUID[T]) Meta(meta core.GlobalMeta) *ZodUUID[T]
- func (z *ZodUUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodUUID[T]) Nilable() *ZodUUID[*string]
- func (z *ZodUUID[T]) Nullish() *ZodUUID[*string]
- func (z *ZodUUID[T]) Optional() *ZodUUID[*string]
- func (z *ZodUUID[T]) Prefault(v string) *ZodUUID[T]
- func (z *ZodUUID[T]) PrefaultFunc(fn func() string) *ZodUUID[T]
- func (z *ZodUUID[T]) RefineAny(fn func(any) bool, params ...any) *ZodUUID[T]
- func (z *ZodUUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodUnion
- func (z *ZodUnion[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodUnion[T, R]) CloneFrom(source any)
- func (z *ZodUnion[T, R]) Default(v T) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) DefaultFunc(fn func() T) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) Describe(desc string) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodUnion[T, R]) IsNilable() bool
- func (z *ZodUnion[T, R]) IsOptional() bool
- func (z *ZodUnion[T, R]) Meta(meta core.GlobalMeta) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodUnion[T, R]) Nilable() *ZodUnion[T, *T]
- func (z *ZodUnion[T, R]) NonOptional() *ZodUnion[T, T]
- func (z *ZodUnion[T, R]) Nullish() *ZodUnion[T, *T]
- func (z *ZodUnion[T, R]) Optional() *ZodUnion[T, *T]
- func (z *ZodUnion[T, R]) Options() []core.ZodSchema
- func (z *ZodUnion[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodUnion[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodUnion[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodUnion[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodUnion[T, R]) Prefault(v T) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) PrefaultFunc(fn func() T) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) Refine(fn func(R) bool, params ...any) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodUnion[T, R]
- func (z *ZodUnion[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodUnion[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- type ZodUnionDef
- type ZodUnionInternals
- type ZodUnknown
- func (z *ZodUnknown[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodUnknown[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) CloneFrom(source any)
- func (z *ZodUnknown[T, R]) Default(v T) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) DefaultFunc(fn func() T) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) Describe(desc string) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) ExactOptional() *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodUnknown[T, R]) IsNilable() bool
- func (z *ZodUnknown[T, R]) IsOptional() bool
- func (z *ZodUnknown[T, R]) Meta(meta core.GlobalMeta) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodUnknown[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
- func (z *ZodUnknown[T, R]) Nilable() *ZodUnknown[T, *T]
- func (z *ZodUnknown[T, R]) NonOptional() *ZodUnknown[T, T]
- func (z *ZodUnknown[T, R]) Nullish() *ZodUnknown[T, *T]
- func (z *ZodUnknown[T, R]) Optional() *ZodUnknown[T, *T]
- func (z *ZodUnknown[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodUnknown[T, R]) Overwrite(transform func(T) T, params ...any) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodUnknown[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodUnknown[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodUnknown[T, R]) Prefault(v T) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) PrefaultFunc(fn func() T) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) Refine(fn func(R) bool, params ...any) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodUnknown[T, R]
- func (z *ZodUnknown[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
- func (z *ZodUnknown[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- func (z *ZodUnknown[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodUnknown[T, R]
- type ZodUnknownDef
- type ZodUnknownInternals
- type ZodXID
- func (z *ZodXID[T]) Default(v string) *ZodXID[T]
- func (z *ZodXID[T]) DefaultFunc(fn func() string) *ZodXID[T]
- func (z *ZodXID[T]) Describe(description string) *ZodXID[T]
- func (z *ZodXID[T]) Meta(meta core.GlobalMeta) *ZodXID[T]
- func (z *ZodXID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
- func (z *ZodXID[T]) Nilable() *ZodXID[*string]
- func (z *ZodXID[T]) Nullish() *ZodXID[*string]
- func (z *ZodXID[T]) Optional() *ZodXID[*string]
- func (z *ZodXID[T]) Prefault(v string) *ZodXID[T]
- func (z *ZodXID[T]) PrefaultFunc(fn func() string) *ZodXID[T]
- func (z *ZodXID[T]) RefineAny(fn func(any) bool, params ...any) *ZodXID[T]
- func (z *ZodXID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
- type ZodXor
- func (z *ZodXor[T, R]) And(other any) *ZodIntersection[any, any]
- func (z *ZodXor[T, R]) CloneFrom(source any)
- func (z *ZodXor[T, R]) Default(v T) *ZodXor[T, R]
- func (z *ZodXor[T, R]) DefaultFunc(fn func() T) *ZodXor[T, R]
- func (z *ZodXor[T, R]) Describe(description string) *ZodXor[T, R]
- func (z *ZodXor[T, R]) Internals() *core.ZodTypeInternals
- func (z *ZodXor[T, R]) IsNilable() bool
- func (z *ZodXor[T, R]) IsOptional() bool
- func (z *ZodXor[T, R]) Meta(meta core.GlobalMeta) *ZodXor[T, R]
- func (z *ZodXor[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
- func (z *ZodXor[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
- func (z *ZodXor[T, R]) Nilable() *ZodXor[T, *T]
- func (z *ZodXor[T, R]) NonOptional() *ZodXor[T, T]
- func (z *ZodXor[T, R]) Nullish() *ZodXor[T, *T]
- func (z *ZodXor[T, R]) Optional() *ZodXor[T, *T]
- func (z *ZodXor[T, R]) Options() []core.ZodSchema
- func (z *ZodXor[T, R]) Or(other any) *ZodUnion[any, any]
- func (z *ZodXor[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
- func (z *ZodXor[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
- func (z *ZodXor[T, R]) Pipe(target core.ZodType[any]) *core.ZodPipe[R, any]
- func (z *ZodXor[T, R]) Prefault(v T) *ZodXor[T, R]
- func (z *ZodXor[T, R]) PrefaultFunc(fn func() T) *ZodXor[T, R]
- func (z *ZodXor[T, R]) Refine(fn func(R) bool, params ...any) *ZodXor[T, R]
- func (z *ZodXor[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodXor[T, R]
- func (z *ZodXor[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
- func (z *ZodXor[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
- type ZodXorDef
- type ZodXorInternals
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilArrayPtr = errors.New("nil pointer to array") ErrNilPtr = errors.New("nil pointer") ErrNotArray = errors.New("expected array or slice") )
Sentinel errors for array validation.
var ( ErrSchemaIsNil = errors.New("schema is nil") ErrSchemaInternalsIsNil = errors.New("schema internals is nil") ErrNoDiscriminatorValues = errors.New("no discriminator values found for field") ErrOptionIsNil = errors.New("option is nil") ErrDuplicateDiscriminator = errors.New("duplicate discriminator value") ErrFailedToBuildDiscriminator = errors.New("failed to build discriminator map") ErrNoValidDiscriminators = errors.New("no valid discriminator values found for field") )
var ( PrecisionMinute = new(-1) // no seconds component PrecisionSecond = new(0) // seconds, no fraction PrecisionDecisecond = new(1) // 1 fractional digit PrecisionCentisecond = new(2) // 2 fractional digits PrecisionMillisecond = new(3) // 3 fractional digits PrecisionMicrosecond = new(6) // 6 fractional digits PrecisionNanosecond = new(9) // 9 fractional digits )
Precision constants control fractional-second digits in ISO 8601 strings.
var ( // ErrNilObjectPointer is returned when a nil pointer is converted to an object. ErrNilObjectPointer = errors.New("nil pointer cannot convert to object") // ErrPickRefinements is returned when Pick is used on a schema with refinements. ErrPickRefinements = errors.New("pick cannot be used on schemas with refinements") // ErrOmitRefinements is returned when Omit is used on a schema with refinements. ErrOmitRefinements = errors.New("omit cannot be used on schemas with refinements") // ErrExtendRefinements is returned when Extend would overwrite keys on a schema with refinements. ErrExtendRefinements = errors.New("extend cannot overwrite keys on schemas with refinements, use SafeExtend") // ErrUnrecognizedKey is returned when strict object parsing encounters an unknown key. ErrUnrecognizedKey = errors.New("unrecognized key") )
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") )
Sentinel errors for record schema operations.
var ( // ErrFieldNotFoundOrNotSettable is returned when a struct field cannot be found or set. ErrFieldNotFoundOrNotSettable = errors.New("field not found or not settable") // ErrCannotAssignToField is returned when a value cannot be assigned to a struct field. ErrCannotAssignToField = errors.New("cannot assign value to field of type") // ErrValueMustBeStruct is returned when a value is not a struct or pointer to struct. ErrValueMustBeStruct = errors.New("value must be a struct or pointer to struct") )
Functions ¶
func ValidateStruct ¶ added in v0.9.0
func ValidateStruct(value any, opts ...FromStructOption) (any, error)
ValidateStruct validates a struct using tags and returns the parsed result. Returns the struct with defaults applied, coercions performed, and all validation issues.
This is the runtime equivalent of FromStruct[T]().Parse(value).
Example:
type Config struct {
Host string `validate:"default=localhost"`
Port int `validate:"min=1000"`
}
result, err := types.ValidateStruct(&Config{Port: 8080}, types.WithTagName("validate"))
config := result.(*Config) // Host is now "localhost"
Types ¶
type BigIntegerConstraint ¶ added in v0.3.0
BigIntegerConstraint restricts values to *big.Int or **big.Int.
type BoolConstraint ¶ added in v0.3.0
BoolConstraint restricts values to bool or *bool.
type Complex64Constraint ¶ added in v0.3.0
Complex64Constraint restricts values to complex64 or *complex64.
type Complex128Constraint ¶ added in v0.3.0
type Complex128Constraint interface {
complex128 | *complex128
}
Complex128Constraint restricts values to complex128 or *complex128.
type ComplexConstraint ¶ added in v0.3.0
type ComplexConstraint interface {
complex64 | complex128 | *complex64 | *complex128
}
ComplexConstraint restricts values to complex64, complex128, or their pointers.
type EmailConstraint ¶ added in v0.3.0
EmailConstraint restricts values to string or *string.
type FloatConstraint ¶ added in v0.3.0
FloatConstraint restricts values to supported float types or their pointers.
type FromStructOption ¶ added in v0.8.0
type FromStructOption func(*fromStructConfig)
FromStructOption configures FromStruct and FromStructPtr.
func WithFieldNameTag ¶ added in v0.11.6
func WithFieldNameTag(name string) FromStructOption
WithFieldNameTag sets the struct tag used for field names (e.g. "yaml", "toml"). It defaults to "json" and controls JSON Schema property names and validation error paths.
func WithTagName ¶ added in v0.8.0
func WithTagName(name string) FromStructOption
WithTagName sets the struct tag name used by FromStruct helpers.
type FunctionConstraint ¶ added in v0.3.0
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
IsoConstraint restricts generic type parameters to string or *string.
type IsoDatetimeOptions ¶ added in v0.3.0
type IsoDatetimeOptions struct {
Precision *int // fractional-second digits; nil = any
Offset bool // allow timezone offsets like +08:00
Local bool // make trailing "Z" optional
}
IsoDatetimeOptions configures ISO 8601 datetime validation.
type IsoTimeOptions ¶ added in v0.3.0
type IsoTimeOptions struct {
Precision *int // fractional-second digits; nil = any, -1 = minute
}
IsoTimeOptions configures ISO 8601 time validation.
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 configures JWT validation behavior.
type LazyConstraint ¶ added in v0.3.0
LazyConstraint restricts values to any or *any for lazy schema types.
type ObjectMode ¶
type ObjectMode string
ObjectMode defines how object validation handles unknown keys.
const ( // ObjectModeStrict rejects unknown keys. ObjectModeStrict ObjectMode = "strict" // ObjectModeStrip removes unknown keys from the parsed result. ObjectModeStrip ObjectMode = "strip" // ObjectModePassthrough preserves unknown keys in the parsed result. ObjectModePassthrough ObjectMode = "passthrough" )
type StringBoolConstraint ¶ added in v0.3.0
StringBoolConstraint restricts values to bool or *bool.
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 configures truthy/falsy values and case sensitivity.
type StringConstraint ¶ added in v0.3.0
StringConstraint restricts values to string or *string.
type TimeConstraint ¶ added in v0.3.0
TimeConstraint restricts values to time.Time or *time.Time.
type TupleConstraint ¶ added in v0.5.4
TupleConstraint defines valid constraint types for tuple schemas.
type URLOptions ¶ added in v0.3.0
type URLOptions struct {
// Hostname is a pattern that the URL's hostname must match.
Hostname *regexp.Regexp
// Protocol is a pattern that the URL's protocol must match.
Protocol *regexp.Regexp
}
URLOptions configures validation for URL schemas.
type ZodAny ¶
ZodAny validates any value with dual generic parameters. T is the base type, and R is the constraint type (T or *T).
func AnyPtr ¶ added in v0.3.0
AnyPtr creates a schema that accepts any value with pointer constraint.
func (*ZodAny[T, R]) And ¶ added in v0.6.0
func (z *ZodAny[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodAny[T, R]) Check ¶
func (z *ZodAny[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodAny[T, R]
Check adds a custom validation function that can push multiple issues.
func (*ZodAny[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodAny[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodAny[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodAny[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional returns a schema that accepts absent keys but rejects explicit nil values.
func (*ZodAny[T, R]) Internals ¶ added in v0.6.0
func (z *ZodAny[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodAny[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodAny[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 the provided metadata in the global registry.
func (*ZodAny[T, R]) MustParse ¶
func (z *ZodAny[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates the input and panics if validation fails.
func (*ZodAny[T, R]) MustStrictParse ¶ added in v0.6.0
func (z *ZodAny[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
MustStrictParse validates the input with compile-time type safety and panics if validation fails.
func (*ZodAny[T, R]) NonOptional ¶ added in v0.3.0
NonOptional removes the optional flag and forces the return type to T.
func (*ZodAny[T, R]) Nullish ¶
Nullish returns a schema that combines optional and nilable modifiers.
func (*ZodAny[T, R]) Optional ¶
Optional returns a pointer-typed schema that accepts missing values.
func (*ZodAny[T, R]) Overwrite ¶ added in v0.3.0
Overwrite applies data transformation while preserving the type structure.
func (*ZodAny[T, R]) Parse ¶
func (z *ZodAny[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates the input and returns a value matching the generic type R.
func (*ZodAny[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates the input and returns an untyped result.
func (*ZodAny[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodAny[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodAny[T, R]) Refine ¶
Refine applies a custom validation function that matches the schema's output type R.
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.
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.
type ZodAnyDef ¶
type ZodAnyDef struct {
core.ZodTypeDef
}
ZodAnyDef holds the configuration for any-value validation.
type ZodAnyInternals ¶
type ZodAnyInternals struct {
core.ZodTypeInternals
Def *ZodAnyDef
}
ZodAnyInternals contains the internal state of an any validator.
type ZodArray ¶
ZodArray is a type-safe fixed-length array validation schema. T is the base array type, R is the constraint type (T or *T).
func Array ¶
Array creates a tuple schema with fixed elements.
Array() - empty tuple
Array([]any{String(), Int()}) - fixed length tuple
Array([]any{String(), Int()}, Bool()) - tuple with rest parameter
func ArrayTyped ¶ added in v0.3.0
ArrayTyped is the generic constructor for tuple schemas.
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.
func (*ZodArray[T, R]) Check ¶
func (z *ZodArray[T, R]) Check(fn func(R, *core.ParsePayload), params ...any) *ZodArray[T, R]
Check adds a custom validation function that can report multiple issues.
func (*ZodArray[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodArray[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodArray[T, R]) Describe ¶ added in v0.5.4
Describe sets a description for this schema in the global registry.
func (*ZodArray[T, R]) Element ¶
Element returns the schema at the given index, or nil if out of range.
func (*ZodArray[T, R]) ExactOptional ¶ added in v0.5.4
ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional, ExactOptional only accepts absent keys in object fields.
func (*ZodArray[T, R]) Internals ¶ added in v0.6.0
func (z *ZodArray[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state for framework usage.
func (*ZodArray[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodArray[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
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]) 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.
func (*ZodArray[T, R]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodArray[T, R]) NonOptional ¶ added in v0.3.0
NonOptional enforces non-nil value constraint, producing a "expected = nonoptional" error when input is nil.
func (*ZodArray[T, R]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodArray[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the value while preserving the original type.
func (*ZodArray[T, R]) Parse ¶
func (z *ZodArray[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns the parsed array value.
func (*ZodArray[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodArray[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodArray[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodArray[T, R]) Rest ¶ added in v0.3.0
Rest returns the rest parameter schema, or nil if none.
func (*ZodArray[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodArray[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
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 to the parsed value.
type ZodArrayDef ¶
type ZodArrayDef struct {
core.ZodTypeDef
Items []core.ZodSchema // Element schemas per position.
Rest core.ZodSchema // Rest schema for variadic elements (nil if none).
}
ZodArrayDef holds the schema definition for fixed-length array validation.
type ZodArrayInternals ¶
type ZodArrayInternals struct {
core.ZodTypeInternals
Def *ZodArrayDef
Items []core.ZodSchema
Rest core.ZodSchema
}
ZodArrayInternals contains the internal state for an array schema.
type ZodBase64 ¶ added in v0.3.0
type ZodBase64[T StringConstraint] struct { *ZodString[T] }
ZodBase64 validates Base64 encoded strings. String modifiers (Min, Max, etc.) are promoted from the embedded *ZodString[T].
func Base64Ptr ¶ added in v0.3.0
Base64Ptr creates a pointer Base64 encoded string validation schema.
func (*ZodBase64[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodBase64[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodBase64[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodBase64[T]) Meta ¶ added in v0.10.5
func (z *ZodBase64[T]) Meta(meta core.GlobalMeta) *ZodBase64[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodBase64[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodBase64[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodBase64[T]) Nilable ¶ added in v0.6.0
Nilable returns a new schema that accepts nil values.
func (*ZodBase64[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodBase64[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodBase64[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodBase64[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodBase64[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodBase64[T]) StrictParse ¶ added in v0.4.0
func (z *ZodBase64[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodBase64URL ¶ added in v0.3.0
type ZodBase64URL[T StringConstraint] struct { *ZodString[T] }
ZodBase64URL validates Base64URL encoded strings. String modifiers (Min, Max, etc.) are promoted from the embedded *ZodString[T].
func Base64URL ¶ added in v0.3.0
func Base64URL(params ...any) *ZodBase64URL[string]
Base64URL creates a Base64URL encoded string validation schema.
func Base64URLPtr ¶ added in v0.3.0
func Base64URLPtr(params ...any) *ZodBase64URL[*string]
Base64URLPtr creates a pointer Base64URL encoded string validation schema.
func (*ZodBase64URL[T]) Default ¶ added in v0.10.5
func (z *ZodBase64URL[T]) Default(v string) *ZodBase64URL[T]
Default sets a fallback value returned when input is nil.
func (*ZodBase64URL[T]) DefaultFunc ¶ added in v0.10.5
func (z *ZodBase64URL[T]) DefaultFunc(fn func() string) *ZodBase64URL[T]
DefaultFunc sets a fallback function called when input is nil.
func (*ZodBase64URL[T]) Describe ¶ added in v0.10.5
func (z *ZodBase64URL[T]) Describe(description string) *ZodBase64URL[T]
Describe attaches a description to this schema via the global registry.
func (*ZodBase64URL[T]) Meta ¶ added in v0.10.5
func (z *ZodBase64URL[T]) Meta(meta core.GlobalMeta) *ZodBase64URL[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodBase64URL[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodBase64URL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodBase64URL[T]) Nilable ¶ added in v0.6.0
func (z *ZodBase64URL[T]) Nilable() *ZodBase64URL[*string]
Nilable returns a new schema that accepts nil values.
func (*ZodBase64URL[T]) Nullish ¶ added in v0.6.0
func (z *ZodBase64URL[T]) Nullish() *ZodBase64URL[*string]
Nullish returns a new schema combining optional and nilable.
func (*ZodBase64URL[T]) Optional ¶ added in v0.6.0
func (z *ZodBase64URL[T]) Optional() *ZodBase64URL[*string]
Optional returns a new schema that accepts nil values.
func (*ZodBase64URL[T]) Prefault ¶ added in v0.10.5
func (z *ZodBase64URL[T]) Prefault(v string) *ZodBase64URL[T]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodBase64URL[T]) PrefaultFunc ¶ added in v0.10.5
func (z *ZodBase64URL[T]) PrefaultFunc(fn func() string) *ZodBase64URL[T]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodBase64URL[T]) RefineAny ¶ added in v0.10.5
func (z *ZodBase64URL[T]) RefineAny(fn func(any) bool, params ...any) *ZodBase64URL[T]
RefineAny adds custom validation that receives the raw value as any.
func (*ZodBase64URL[T]) StrictParse ¶ added in v0.4.0
func (z *ZodBase64URL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodBigInt ¶
type ZodBigInt[T BigIntegerConstraint] struct { // contains filtered or unexported fields }
ZodBigInt is a type-safe big.Int validation schema.
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
CoercedBigInt creates a coerced *big.Int schema.
func CoercedBigIntPtr ¶ added in v0.3.0
CoercedBigIntPtr creates a coerced **big.Int schema.
func (*ZodBigInt[T]) CloneFrom ¶
CloneFrom copies configuration from another schema of the same type.
func (*ZodBigInt[T]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodBigInt[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodBigInt[T]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodBigInt[T]) Internals ¶ added in v0.6.0
func (z *ZodBigInt[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodBigInt[T]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodBigInt[T]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
func (*ZodBigInt[T]) Meta ¶ added in v0.3.1
func (z *ZodBigInt[T]) Meta(meta core.GlobalMeta) *ZodBigInt[T]
Meta stores metadata for this schema in the global registry.
func (*ZodBigInt[T]) MultipleOf ¶
MultipleOf adds multiple-of validation.
func (*ZodBigInt[T]) MustParse ¶
func (z *ZodBigInt[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse panics on validation failure.
func (*ZodBigInt[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodBigInt[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodBigInt[T]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodBigInt[T]) NonNegative ¶
NonNegative adds non-negative number validation (>= 0).
func (*ZodBigInt[T]) NonOptional ¶ added in v0.3.0
NonOptional removes the optional flag, returning a *big.Int constraint.
func (*ZodBigInt[T]) NonPositive ¶
NonPositive adds non-positive number validation (<= 0).
func (*ZodBigInt[T]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodBigInt[T]) Overwrite ¶ added in v0.3.0
Overwrite transforms the value while preserving the same type.
func (*ZodBigInt[T]) Parse ¶
func (z *ZodBigInt[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value matching the generic type T.
func (*ZodBigInt[T]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodBigInt[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodBigInt[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodBigInt[T]) StrictParse ¶ added in v0.4.0
func (z *ZodBigInt[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodBigIntDef ¶
type ZodBigIntDef struct {
core.ZodTypeDef
}
ZodBigIntDef holds the configuration for big.Int validation.
type ZodBigIntInternals ¶
type ZodBigIntInternals struct {
core.ZodTypeInternals
Def *ZodBigIntDef
}
ZodBigIntInternals contains the internal state of a big.Int validator.
type ZodBool ¶
type ZodBool[T BoolConstraint] struct { // contains filtered or unexported fields }
ZodBool is a type-safe boolean validation schema.
func BoolTyped ¶ added in v0.3.0
func BoolTyped[T BoolConstraint](params ...any) *ZodBool[T]
BoolTyped is the generic constructor for boolean schemas.
func CoercedBool ¶ added in v0.2.1
CoercedBool creates a coerced bool schema that converts input.
func CoercedBoolPtr ¶ added in v0.3.0
CoercedBoolPtr creates a coerced *bool schema that converts input.
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.
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.
func (*ZodBool[T]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodBool[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodBool[T]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodBool[T]) ExactOptional ¶ added in v0.5.4
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodBool[T]) Internals ¶ added in v0.6.0
func (z *ZodBool[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodBool[T]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodBool[T]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 in the global registry.
func (*ZodBool[T]) MustParse ¶
func (z *ZodBool[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse panics on validation failure.
func (*ZodBool[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodBool[T]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodBool[T]) NonOptional ¶ added in v0.3.0
NonOptional removes the optional flag, returning a bool constraint.
func (*ZodBool[T]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodBool[T]) Overwrite ¶ added in v0.3.0
Overwrite transforms the input value while preserving the original type.
func (*ZodBool[T]) Parse ¶
func (z *ZodBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value matching the generic type T.
func (*ZodBool[T]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodBool[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodBool[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodBool[T]) Refine ¶
Refine applies a custom validation function matching the schema's output type T.
func (*ZodBool[T]) RefineAny ¶
RefineAny applies a custom validation function that receives the raw value.
func (*ZodBool[T]) StrictParse ¶ added in v0.4.0
func (z *ZodBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodBoolDef ¶
type ZodBoolDef struct {
core.ZodTypeDef
}
ZodBoolDef holds the configuration for boolean validation.
type ZodBoolInternals ¶
type ZodBoolInternals struct {
core.ZodTypeInternals
Def *ZodBoolDef
}
ZodBoolInternals contains the internal state of a boolean validator.
type ZodCIDRv4 ¶
type ZodCIDRv4[T StringConstraint] struct{ *ZodString[T] }
ZodCIDRv4 validates strings in CIDRv4 notation format.
func CoercedCIDRv4 ¶ added in v0.3.0
CoercedCIDRv4 creates a coerced CIDRv4 schema that attempts string conversion.
func (*ZodCIDRv4[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil.
func (*ZodCIDRv4[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodCIDRv4[T]) Meta ¶ added in v0.10.5
func (z *ZodCIDRv4[T]) Meta(meta core.GlobalMeta) *ZodCIDRv4[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodCIDRv4[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodCIDRv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodCIDRv4[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodCIDRv4[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodCIDRv4[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodCIDRv4[T]) RefineAny ¶
RefineAny adds custom validation that receives the raw value as any.
func (*ZodCIDRv4[T]) StrictParse ¶ added in v0.4.0
func (z *ZodCIDRv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodCIDRv6 ¶
type ZodCIDRv6[T StringConstraint] struct{ *ZodString[T] }
ZodCIDRv6 validates strings in CIDRv6 notation format.
func CoercedCIDRv6 ¶ added in v0.3.0
CoercedCIDRv6 creates a coerced CIDRv6 schema that attempts string conversion.
func (*ZodCIDRv6[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil.
func (*ZodCIDRv6[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodCIDRv6[T]) Meta ¶ added in v0.10.5
func (z *ZodCIDRv6[T]) Meta(meta core.GlobalMeta) *ZodCIDRv6[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodCIDRv6[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodCIDRv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodCIDRv6[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodCIDRv6[T]) Prefault ¶ added in v0.3.0
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodCIDRv6[T]) PrefaultFunc ¶ added in v0.3.0
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodCIDRv6[T]) RefineAny ¶
RefineAny adds custom validation that receives the raw value as any.
func (*ZodCIDRv6[T]) StrictParse ¶ added in v0.4.0
func (z *ZodCIDRv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodCUID ¶ added in v0.3.0
type ZodCUID[T StringConstraint] struct{ *ZodString[T] }
ZodCUID validates strings in CUID format.
func (*ZodCUID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodCUID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodCUID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodCUID[T]) Meta ¶ added in v0.10.5
func (z *ZodCUID[T]) Meta(meta core.GlobalMeta) *ZodCUID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodCUID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodCUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodCUID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodCUID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodCUID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodCUID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodCUID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodCUID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodCUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodCUID2 ¶ added in v0.3.0
type ZodCUID2[T StringConstraint] struct{ *ZodString[T] }
ZodCUID2 validates strings in CUID2 format.
func CUID2 ¶ added in v0.7.0
CUID2 creates a CUID2 schema for next-generation collision-resistant identifiers.
func (*ZodCUID2[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodCUID2[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodCUID2[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodCUID2[T]) Meta ¶ added in v0.10.5
func (z *ZodCUID2[T]) Meta(meta core.GlobalMeta) *ZodCUID2[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodCUID2[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodCUID2[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodCUID2[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodCUID2[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodCUID2[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodCUID2[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodCUID2[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodCUID2[T]) StrictParse ¶ added in v0.4.0
func (z *ZodCUID2[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodComplex ¶
type ZodComplex[T ComplexConstraint] struct { // contains filtered or unexported fields }
ZodComplex is a type-safe complex number validation schema.
func CoercedComplex ¶ added in v0.3.0
func CoercedComplex(params ...any) *ZodComplex[complex128]
CoercedComplex creates a coerced complex128 schema (default alias).
func CoercedComplex64 ¶ added in v0.2.1
func CoercedComplex64(params ...any) *ZodComplex[complex64]
CoercedComplex64 creates a coerced complex64 schema.
func CoercedComplex64Ptr ¶ added in v0.3.0
func CoercedComplex64Ptr(params ...any) *ZodComplex[*complex64]
CoercedComplex64Ptr creates a coerced *complex64 schema.
func CoercedComplex128 ¶ added in v0.2.1
func CoercedComplex128(params ...any) *ZodComplex[complex128]
CoercedComplex128 creates a coerced complex128 schema.
func CoercedComplex128Ptr ¶ added in v0.3.0
func CoercedComplex128Ptr(params ...any) *ZodComplex[*complex128]
CoercedComplex128Ptr creates a coerced *complex128 schema.
func CoercedComplexPtr ¶ added in v0.3.0
func CoercedComplexPtr(params ...any) *ZodComplex[*complex128]
CoercedComplexPtr creates a coerced *complex128 schema (default alias).
func Complex ¶
func Complex(params ...any) *ZodComplex[complex128]
Complex creates a complex128 schema (default alias).
func Complex64 ¶
func Complex64(params ...any) *ZodComplex[complex64]
Complex64 creates a complex64 schema.
func Complex64Ptr ¶ added in v0.3.0
func Complex64Ptr(params ...any) *ZodComplex[*complex64]
Complex64Ptr creates a *complex64 schema.
func Complex128 ¶
func Complex128(params ...any) *ZodComplex[complex128]
Complex128 creates a complex128 schema.
func Complex128Ptr ¶ added in v0.3.0
func Complex128Ptr(params ...any) *ZodComplex[*complex128]
Complex128Ptr creates a *complex128 schema.
func ComplexPtr ¶ added in v0.3.0
func ComplexPtr(params ...any) *ZodComplex[*complex128]
ComplexPtr creates a *complex128 schema (default alias).
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.
func (*ZodComplex[T]) And ¶ added in v0.6.0
func (z *ZodComplex[T]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodComplex[T]) CloneFrom ¶
func (z *ZodComplex[T]) CloneFrom(source any)
CloneFrom copies configuration from another schema of the same type.
func (*ZodComplex[T]) Coerce ¶
func (z *ZodComplex[T]) Coerce(input any) (any, bool)
Coerce converts input to the target complex type.
func (*ZodComplex[T]) Default ¶
func (z *ZodComplex[T]) Default(v complex128) *ZodComplex[T]
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodComplex[T]) DefaultFunc ¶
func (z *ZodComplex[T]) DefaultFunc(fn func() complex128) *ZodComplex[T]
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodComplex[T]) Describe ¶ added in v0.5.4
func (z *ZodComplex[T]) Describe(desc string) *ZodComplex[T]
Describe registers a description in the global registry.
func (*ZodComplex[T]) ExactOptional ¶ added in v0.6.0
func (z *ZodComplex[T]) ExactOptional() *ZodComplex[T]
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodComplex[T]) Finite ¶ added in v0.3.0
func (z *ZodComplex[T]) Finite(params ...any) *ZodComplex[T]
Finite validates that both real and imaginary parts are finite.
func (*ZodComplex[T]) Gt ¶
func (z *ZodComplex[T]) Gt(value float64, params ...any) *ZodComplex[T]
Gt adds greater-than magnitude validation (exclusive).
func (*ZodComplex[T]) Gte ¶
func (z *ZodComplex[T]) Gte(value float64, params ...any) *ZodComplex[T]
Gte adds greater-than-or-equal magnitude validation (inclusive).
func (*ZodComplex[T]) Internals ¶ added in v0.6.0
func (z *ZodComplex[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodComplex[T]) IsNilable ¶ added in v0.3.0
func (z *ZodComplex[T]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodComplex[T]) IsOptional ¶ added in v0.3.0
func (z *ZodComplex[T]) IsOptional() bool
IsOptional reports whether 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 magnitude validation (exclusive).
func (*ZodComplex[T]) Lte ¶
func (z *ZodComplex[T]) Lte(value float64, params ...any) *ZodComplex[T]
Lte adds less-than-or-equal magnitude validation (inclusive).
func (*ZodComplex[T]) Max ¶
func (z *ZodComplex[T]) Max(maximum float64, params ...any) *ZodComplex[T]
Max adds maximum magnitude validation.
func (*ZodComplex[T]) Meta ¶ added in v0.3.1
func (z *ZodComplex[T]) Meta(meta core.GlobalMeta) *ZodComplex[T]
Meta stores metadata in the global registry.
func (*ZodComplex[T]) Min ¶
func (z *ZodComplex[T]) Min(minimum float64, params ...any) *ZodComplex[T]
Min adds minimum magnitude validation.
func (*ZodComplex[T]) MustParse ¶
func (z *ZodComplex[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse panics on validation failure.
func (*ZodComplex[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodComplex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodComplex[T]) Negative ¶
func (z *ZodComplex[T]) Negative(params ...any) *ZodComplex[T]
Negative adds negative validation (< 0) for complex magnitude.
func (*ZodComplex[T]) Nilable ¶
func (z *ZodComplex[T]) Nilable() *ZodComplex[*complex128]
Nilable returns a schema that accepts nil values with pointer constraint.
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 returns a schema that accepts nil values with pointer constraint.
func (*ZodComplex[T]) Or ¶ added in v0.6.0
func (z *ZodComplex[T]) Or(other any) *ZodUnion[any, any]
Or creates a union with another schema.
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.
func (*ZodComplex[T]) Parse ¶
func (z *ZodComplex[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value matching the generic type T.
func (*ZodComplex[T]) ParseAny ¶ added in v0.3.0
func (z *ZodComplex[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
ParseAny validates input and returns an untyped result.
func (*ZodComplex[T]) Positive ¶
func (z *ZodComplex[T]) Positive(params ...any) *ZodComplex[T]
Positive adds positive magnitude validation (> 0).
func (*ZodComplex[T]) Prefault ¶
func (z *ZodComplex[T]) Prefault(v complex128) *ZodComplex[T]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodComplex[T]) PrefaultFunc ¶
func (z *ZodComplex[T]) PrefaultFunc(fn func() complex128) *ZodComplex[T]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodComplex[T]) Refine ¶
func (z *ZodComplex[T]) Refine(fn func(T) bool, params ...any) *ZodComplex[T]
Refine applies a custom validation function matching the schema's output type T.
func (*ZodComplex[T]) RefineAny ¶
func (z *ZodComplex[T]) RefineAny(fn func(any) bool, params ...any) *ZodComplex[T]
RefineAny applies a custom validation function that receives the raw value.
func (*ZodComplex[T]) StrictParse ¶ added in v0.4.0
func (z *ZodComplex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
func (*ZodComplex[T]) Transform ¶
func (z *ZodComplex[T]) Transform(fn func(complex128, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
Transform applies a transformation function to the parsed value.
type ZodComplexDef ¶
type ZodComplexDef struct {
core.ZodTypeDef
}
ZodComplexDef holds the configuration for complex number validation.
type ZodComplexInternals ¶
type ZodComplexInternals struct {
core.ZodTypeInternals
Def *ZodComplexDef
}
ZodComplexInternals contains the internal state of a complex validator.
type ZodDiscriminatedUnion ¶
ZodDiscriminatedUnion is a type-safe discriminated union validation schema.
func DiscriminatedUnion ¶
DiscriminatedUnion creates a discriminated union schema with value constraint.
func DiscriminatedUnionPtr ¶ added in v0.3.0
func DiscriminatedUnionPtr(disc string, options []any, args ...any) *ZodDiscriminatedUnion[any, *any]
DiscriminatedUnionPtr creates a discriminated union schema with pointer constraint.
func DiscriminatedUnionTyped ¶ added in v0.3.0
func DiscriminatedUnionTyped[T any, R any](disc string, options []any, args ...any) *ZodDiscriminatedUnion[T, R]
DiscriminatedUnionTyped creates a typed discriminated union schema.
func (*ZodDiscriminatedUnion[T, R]) CloneFrom ¶
func (z *ZodDiscriminatedUnion[T, R]) CloneFrom(source any)
CloneFrom copies configuration from another schema of the same type.
func (*ZodDiscriminatedUnion[T, R]) Default ¶
func (z *ZodDiscriminatedUnion[T, R]) Default(v T) *ZodDiscriminatedUnion[T, R]
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodDiscriminatedUnion[T, R]) DefaultFunc ¶
func (z *ZodDiscriminatedUnion[T, R]) DefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodDiscriminatedUnion[T, R]) Describe ¶ added in v0.5.4
func (z *ZodDiscriminatedUnion[T, R]) Describe(desc string) *ZodDiscriminatedUnion[T, R]
Describe registers a description in the global registry.
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 a copy of the discriminator-to-schema mapping.
func (*ZodDiscriminatedUnion[T, R]) Internals ¶ added in v0.6.0
func (z *ZodDiscriminatedUnion[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodDiscriminatedUnion[T, R]) IsNilable ¶ added in v0.3.0
func (z *ZodDiscriminatedUnion[T, R]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodDiscriminatedUnion[T, R]) IsOptional ¶ added in v0.3.0
func (z *ZodDiscriminatedUnion[T, R]) IsOptional() bool
IsOptional reports whether 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 in the global registry.
func (*ZodDiscriminatedUnion[T, R]) MustParse ¶
func (z *ZodDiscriminatedUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse panics on validation failure.
func (*ZodDiscriminatedUnion[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodDiscriminatedUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodDiscriminatedUnion[T, R]) Nilable ¶
func (z *ZodDiscriminatedUnion[T, R]) Nilable() *ZodDiscriminatedUnion[T, *T]
Nilable returns a schema that accepts nil values with 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 returns a schema that accepts nil values with pointer constraint.
func (*ZodDiscriminatedUnion[T, R]) Options ¶
func (z *ZodDiscriminatedUnion[T, R]) Options() []core.ZodSchema
Options returns a copy of 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 and returns a value matching the constraint type R.
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 input and returns an untyped result.
func (*ZodDiscriminatedUnion[T, R]) Prefault ¶
func (z *ZodDiscriminatedUnion[T, R]) Prefault(v T) *ZodDiscriminatedUnion[T, R]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodDiscriminatedUnion[T, R]) PrefaultFunc ¶
func (z *ZodDiscriminatedUnion[T, R]) PrefaultFunc(fn func() T) *ZodDiscriminatedUnion[T, R]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodDiscriminatedUnion[T, R]) Refine ¶
func (z *ZodDiscriminatedUnion[T, R]) Refine(fn func(R) bool, params ...any) *ZodDiscriminatedUnion[T, R]
Refine applies a custom validation function matching the schema's output type R.
func (*ZodDiscriminatedUnion[T, R]) RefineAny ¶
func (z *ZodDiscriminatedUnion[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodDiscriminatedUnion[T, R]
RefineAny applies a custom validation function that receives the raw value.
func (*ZodDiscriminatedUnion[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodDiscriminatedUnion[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
func (*ZodDiscriminatedUnion[T, R]) Transform ¶
func (z *ZodDiscriminatedUnion[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform applies a transformation function to the parsed value.
type ZodDiscriminatedUnionDef ¶
type ZodDiscriminatedUnionDef struct {
core.ZodTypeDef
Discriminator string
Options []core.ZodSchema
}
ZodDiscriminatedUnionDef holds the configuration for discriminated union validation.
type ZodDiscriminatedUnionInternals ¶
type ZodDiscriminatedUnionInternals struct {
core.ZodTypeInternals
Def *ZodDiscriminatedUnionDef
Discriminator string
Options []core.ZodSchema
DiscMap map[any]core.ZodSchema
}
ZodDiscriminatedUnionInternals contains the internal state of a discriminated union validator.
type ZodE164 ¶ added in v0.5.4
type ZodE164[T StringConstraint] struct{ *ZodString[T] }
ZodE164 validates strings in E.164 phone number format.
func CoercedE164 ¶ added in v0.6.0
CoercedE164 creates a coerced E164 schema that attempts string conversion.
func (*ZodE164[T]) Default ¶ added in v0.5.4
Default sets a fallback value returned when input is nil.
func (*ZodE164[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodE164[T]) Describe ¶ added in v0.5.4
Describe attaches a description to this schema via the global registry.
func (*ZodE164[T]) Meta ¶ added in v0.10.5
func (z *ZodE164[T]) Meta(meta core.GlobalMeta) *ZodE164[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodE164[T]) MustStrictParse ¶ added in v0.5.4
func (z *ZodE164[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodE164[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodE164[T]) Optional ¶ added in v0.5.4
Optional returns a new schema that accepts nil values.
func (*ZodE164[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodE164[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodE164[T]) RefineAny ¶ added in v0.5.7
RefineAny adds custom validation that receives the raw value as any.
func (*ZodE164[T]) StrictParse ¶ added in v0.5.4
func (z *ZodE164[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodEmail ¶ added in v0.3.0
type ZodEmail[T EmailConstraint] struct { *ZodString[T] }
ZodEmail validates strings as email addresses. String modifiers (Min, Max, Regex, etc.) and Pipe/Transform are promoted from the embedded *ZodString[T].
func EmailTyped ¶ added in v0.3.0
func EmailTyped[T EmailConstraint](params ...any) *ZodEmail[T]
EmailTyped creates an email validation schema with the given type constraint.
func (*ZodEmail[T]) Browser ¶ added in v0.3.0
Browser switches to the browser-compatible email pattern.
func (*ZodEmail[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodEmail[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodEmail[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodEmail[T]) Meta ¶ added in v0.10.5
func (z *ZodEmail[T]) Meta(meta core.GlobalMeta) *ZodEmail[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodEmail[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodEmail[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodEmail[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodEmail[T]) Optional ¶ added in v0.3.0
Optional returns a new schema that accepts nil values.
func (*ZodEmail[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodEmail[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodEmail[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodEmail[T]) StrictParse ¶ added in v0.4.0
func (z *ZodEmail[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodEmoji ¶ added in v0.3.0
type ZodEmoji[T StringConstraint] struct { *ZodString[T] }
ZodEmoji validates strings containing only emoji characters. String modifiers (Min, Max, Regex, etc.) are promoted from the embedded *ZodString[T].
func (*ZodEmoji[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodEmoji[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodEmoji[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodEmoji[T]) Meta ¶ added in v0.10.5
func (z *ZodEmoji[T]) Meta(meta core.GlobalMeta) *ZodEmoji[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodEmoji[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodEmoji[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodEmoji[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodEmoji[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodEmoji[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodEmoji[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodEmoji[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodEmoji[T]) StrictParse ¶ added in v0.4.0
func (z *ZodEmoji[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodEnum ¶
type ZodEnum[T comparable, R any] struct { // contains filtered or unexported fields }
ZodEnum represents a type-safe enum validation schema. The type parameter T is the base comparable type, and R is the constraint type (either T or *T).
func Enum ¶
func Enum[T comparable](values ...T) *ZodEnum[T, T]
Enum creates an enum schema from the provided values with automatic type inference.
func EnumMap ¶
func EnumMap[T comparable](entries map[string]T, params ...any) *ZodEnum[T, T]
EnumMap creates an enum schema from a 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 a pointer-capable enum schema from a 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.
func EnumPtr ¶ added in v0.3.0
func EnumPtr[T comparable](values ...T) *ZodEnum[T, *T]
EnumPtr creates a pointer-capable enum schema from values.
func EnumSlice ¶
func EnumSlice[T comparable](values []T) *ZodEnum[T, T]
EnumSlice creates an enum schema from a slice of values.
func EnumSlicePtr ¶ added in v0.3.0
func EnumSlicePtr[T comparable](values []T) *ZodEnum[T, *T]
EnumSlicePtr creates a pointer-capable enum schema from a slice of values.
func (*ZodEnum[T, R]) And ¶ added in v0.6.0
func (z *ZodEnum[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodEnum[T, R]) Check ¶ added in v0.6.0
func (z *ZodEnum[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodEnum[T, R]
Check adds a custom validation function that can push multiple issues.
func (*ZodEnum[T, R]) CloneFrom ¶ added in v0.3.0
CloneFrom copies configuration from another schema while preserving the original checks.
func (*ZodEnum[T, R]) Default ¶
Default sets a fallback value returned when input is nil. This short-circuits validation and returns the default value immediately.
func (*ZodEnum[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil. This short-circuits validation and returns the default value immediately.
func (*ZodEnum[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodEnum[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional returns a schema that accepts absent keys but rejects explicit nil values. Unlike Optional, ExactOptional only accepts absent keys in object fields.
func (*ZodEnum[T, R]) Exclude ¶
Exclude creates a sub-enum without the specified keys. Non-existent keys are silently ignored.
func (*ZodEnum[T, R]) Extract ¶
Extract creates a sub-enum containing only the specified keys. Non-existent keys are silently ignored.
func (*ZodEnum[T, R]) Internals ¶ added in v0.6.0
func (z *ZodEnum[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodEnum[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodEnum[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 in the global registry.
func (*ZodEnum[T, R]) MustParse ¶
func (z *ZodEnum[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input 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 provides compile-time type safety and panics on failure.
func (*ZodEnum[T, R]) Nilable ¶
Nilable returns a new schema that accepts nil values, with *T constraint.
func (*ZodEnum[T, R]) NonOptional ¶ added in v0.6.0
NonOptional removes the optional flag, returning a T constraint.
func (*ZodEnum[T, R]) Nullish ¶
Nullish returns a new schema combining optional and nilable modifiers.
func (*ZodEnum[T, R]) Optional ¶
Optional returns a new schema that accepts nil, with *T constraint.
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 and returns a value matching the generic type R.
func (*ZodEnum[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns any type for runtime interface usage.
func (*ZodEnum[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline when input is nil.
func (*ZodEnum[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline when input is nil.
func (*ZodEnum[T, R]) Refine ¶
Refine applies type-safe validation matching the schema's output type R. The callback receives nil for *T schemas when the value is nil (Zod v4 semantics).
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 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 to the parsed enum value.
type ZodEnumDef ¶
type ZodEnumDef[T comparable] struct { core.ZodTypeDef // Entries maps enum keys to enum values. Entries map[string]T }
ZodEnumDef defines the configuration for enum validation.
type ZodEnumInternals ¶
type ZodEnumInternals[T comparable] struct { core.ZodTypeInternals // Def points to the schema definition. Def *ZodEnumDef[T] // Entries maps enum keys to enum values. Entries map[string]T // Values stores the allowed enum values for membership checks. Values map[T]struct{} }
ZodEnumInternals contains the internal state for enum validators.
type ZodFile ¶
ZodFile validates file inputs with constraint types T (base) and R (output). Supported types: *os.File, *multipart.FileHeader, multipart.File.
func FilePtr ¶ added in v0.3.0
FilePtr creates a new file validation schema with pointer constraint.
func FileTyped ¶ added in v0.3.0
FileTyped creates a new file schema with specific constraint types.
func (*ZodFile[T, R]) And ¶ added in v0.6.0
func (z *ZodFile[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodFile[T, R]) Check ¶ added in v0.6.0
func (z *ZodFile[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodFile[T, R]
Check adds a custom validation function that can push multiple issues.
func (*ZodFile[T, R]) CloneFrom ¶
CloneFrom copies configuration from another schema of the same type.
func (*ZodFile[T, R]) Default ¶
Default sets a fallback value when input is nil (short-circuits validation).
func (*ZodFile[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodFile[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodFile[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodFile[T, R]) Internals ¶ added in v0.6.0
func (z *ZodFile[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodFile[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodFile[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
func (*ZodFile[T, R]) Meta ¶ added in v0.3.1
func (z *ZodFile[T, R]) Meta(meta core.GlobalMeta) *ZodFile[T, R]
Meta stores metadata for this file schema in the global registry.
func (*ZodFile[T, R]) MustParse ¶
func (z *ZodFile[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on failure.
func (*ZodFile[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodFile[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse provides compile-time type safety and panics on failure.
func (*ZodFile[T, R]) Nilable ¶
Nilable returns a new schema that accepts nil values, with pointer constraint.
func (*ZodFile[T, R]) Nullish ¶
Nullish returns a new schema combining optional and nilable modifiers.
func (*ZodFile[T, R]) Optional ¶
Optional returns a new schema that accepts nil with pointer constraint.
func (*ZodFile[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the input value while preserving the original type.
func (*ZodFile[T, R]) Parse ¶
func (z *ZodFile[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns a value of type R.
func (*ZodFile[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns any type for runtime interface usage.
func (*ZodFile[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodFile[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodFile[T, R]) RefineAny ¶
RefineAny applies a custom validation function receiving the raw value.
func (*ZodFile[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodFile[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse provides compile-time type safety by requiring exact type T.
func (*ZodFile[T, R]) Transform ¶
func (z *ZodFile[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform applies a transformation function to the parsed value.
type ZodFileDef ¶
type ZodFileDef struct {
core.ZodTypeDef
}
ZodFileDef defines the configuration for file validation.
type ZodFileInternals ¶
type ZodFileInternals struct {
core.ZodTypeInternals
Def *ZodFileDef
}
ZodFileInternals contains file validator internal state.
type ZodFloat ¶
type ZodFloat[T FloatConstraint, R any] = ZodFloatTyped[T, R]
ZodFloat is a generic type alias for ZodFloatTyped.
type ZodFloatDef ¶
type ZodFloatDef struct {
core.ZodTypeDef
}
ZodFloatDef defines the configuration for float validation.
type ZodFloatInternals ¶
type ZodFloatInternals struct {
core.ZodTypeInternals
Def *ZodFloatDef
}
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 is the base type (float32, float64), R is the 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. 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.
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 that can report multiple issues.
Example:
schema := Float64().Check(func(value float64, payload *core.ParsePayload) {
if value < 0 {
payload.AddIssue(core.NewIssue("value must be positive"))
}
})
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 converts input to the target float type.
func (*ZodFloatTyped[T, R]) Default ¶ added in v0.3.0
func (z *ZodFloatTyped[T, R]) Default(v float64) *ZodFloatTyped[T, R]
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodFloatTyped[T, R]) DefaultFunc ¶ added in v0.3.0
func (z *ZodFloatTyped[T, R]) DefaultFunc(fn func() float64) *ZodFloatTyped[T, R]
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
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.
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.
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]) 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]) Internals ¶ added in v0.6.0
func (z *ZodFloatTyped[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodFloatTyped[T, R]) IsNilable ¶ added in v0.3.0
func (z *ZodFloatTyped[T, R]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodFloatTyped[T, R]) IsOptional ¶ added in v0.3.0
func (z *ZodFloatTyped[T, R]) IsOptional() bool
IsOptional reports whether 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 validates with compile-time type safety and panics on error.
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).
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.
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).
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.
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.
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 doesn't change 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 validates input and returns a value matching the constraint type R.
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 an untyped result.
func (*ZodFloatTyped[T, R]) Pipe ¶ added in v0.3.0
Pipe creates a pipeline that feeds the parsed value into another schema.
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 sets a fallback value that goes through the full validation pipeline.
func (*ZodFloatTyped[T, R]) PrefaultFunc ¶ added in v0.3.0
func (z *ZodFloatTyped[T, R]) PrefaultFunc(fn func() float64) *ZodFloatTyped[T, R]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
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. Nil values bypass validation for nilable schemas per Zod v4 semantics.
Example:
schema := Float64().Refine(func(f float64) bool {
return f > 0 && f < 100
}, "value must be between 0 and 100")
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 that accepts any type.
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).
func (*ZodFloatTyped[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodFloatTyped[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
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 to the parsed float value.
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 (Zod v4 API compatibility).
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 validation schema with constraint type any.
func FunctionPtr ¶ added in v0.3.0
func FunctionPtr(params ...any) *ZodFunction[*any]
FunctionPtr creates a function validation schema with constraint type *any.
func FunctionTyped ¶ added in v0.3.0
func FunctionTyped[T FunctionConstraint](params ...any) *ZodFunction[T]
FunctionTyped creates a function validation schema with the specified constraint type.
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 sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodFunction[T]) DefaultFunc ¶
func (z *ZodFunction[T]) DefaultFunc(fn func() any) *ZodFunction[T]
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
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.
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(schema core.ZodType[any]) *ZodFunction[T]
Input sets the input schema for function arguments.
func (*ZodFunction[T]) Internals ¶ added in v0.6.0
func (z *ZodFunction[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodFunction[T]) IsNilable ¶ added in v0.3.0
func (z *ZodFunction[T]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodFunction[T]) IsOptional ¶ added in v0.3.0
func (z *ZodFunction[T]) IsOptional() bool
IsOptional reports whether this schema accepts undefined or 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 validates input and 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 with compile-time type safety and panics on error.
func (*ZodFunction[T]) Nilable ¶
func (z *ZodFunction[T]) Nilable() *ZodFunction[*any]
Nilable returns a schema that accepts nil with constraint type *any.
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 returns a schema that accepts nil with constraint type *any.
func (*ZodFunction[T]) Output ¶
func (z *ZodFunction[T]) Output(schema core.ZodType[any]) *ZodFunction[T]
Output sets the output schema for function return values.
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.
func (*ZodFunction[T]) Parse ¶
func (z *ZodFunction[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a function value.
func (*ZodFunction[T]) ParseAny ¶ added in v0.3.0
func (z *ZodFunction[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
ParseAny validates input and returns an untyped result.
func (*ZodFunction[T]) Prefault ¶
func (z *ZodFunction[T]) Prefault(v any) *ZodFunction[T]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodFunction[T]) PrefaultFunc ¶
func (z *ZodFunction[T]) PrefaultFunc(fn func() any) *ZodFunction[T]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodFunction[T]) Refine ¶
func (z *ZodFunction[T]) Refine(fn func(T) bool, params ...any) *ZodFunction[T]
Refine adds a custom validation function.
func (*ZodFunction[T]) RefineAny ¶
func (z *ZodFunction[T]) RefineAny(fn func(any) bool, params ...any) *ZodFunction[T]
RefineAny adds a custom validation function that accepts any type.
func (*ZodFunction[T]) StrictParse ¶ added in v0.4.0
func (z *ZodFunction[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
func (*ZodFunction[T]) Transform ¶
func (z *ZodFunction[T]) Transform(fn func(any, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
Transform creates a transformation pipeline.
type ZodFunctionDef ¶
ZodFunctionDef defines the configuration for function validation.
type ZodFunctionInternals ¶
type ZodFunctionInternals struct {
core.ZodTypeInternals
Def *ZodFunctionDef
Input core.ZodType[any]
Output core.ZodType[any]
}
ZodFunctionInternals contains function validator internal state.
type ZodGUID ¶ added in v0.5.5
type ZodGUID[T StringConstraint] struct{ *ZodString[T] }
ZodGUID validates strings in GUID format (8-4-4-4-12 hex pattern).
func (*ZodGUID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodGUID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodGUID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodGUID[T]) Meta ¶ added in v0.10.5
func (z *ZodGUID[T]) Meta(meta core.GlobalMeta) *ZodGUID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodGUID[T]) MustStrictParse ¶ added in v0.5.5
func (z *ZodGUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodGUID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodGUID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodGUID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodGUID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodGUID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodGUID[T]) StrictParse ¶ added in v0.5.5
func (z *ZodGUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodHex ¶ added in v0.5.4
type ZodHex[T StringConstraint] struct { *ZodString[T] }
ZodHex validates hexadecimal strings. String modifiers (Min, Max, etc.) are promoted from the embedded *ZodString[T].
func (*ZodHex[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodHex[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodHex[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodHex[T]) Meta ¶ added in v0.10.5
func (z *ZodHex[T]) Meta(meta core.GlobalMeta) *ZodHex[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodHex[T]) MustStrictParse ¶ added in v0.5.4
func (z *ZodHex[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodHex[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodHex[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodHex[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodHex[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodHex[T]) StrictParse ¶ added in v0.5.4
func (z *ZodHex[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodHostname ¶ added in v0.5.4
type ZodHostname[T StringConstraint] struct{ *ZodString[T] }
ZodHostname validates strings in hostname format.
func CoercedHostname ¶ added in v0.6.0
func CoercedHostname(params ...any) *ZodHostname[string]
CoercedHostname creates a coerced hostname schema that attempts string conversion.
func Hostname ¶ added in v0.5.4
func Hostname(params ...any) *ZodHostname[string]
Hostname creates a hostname validation schema.
func HostnamePtr ¶ added in v0.5.4
func HostnamePtr(params ...any) *ZodHostname[*string]
HostnamePtr creates a pointer hostname validation schema.
func (*ZodHostname[T]) Default ¶ added in v0.5.4
func (z *ZodHostname[T]) Default(v string) *ZodHostname[T]
Default sets a fallback value returned when input is nil.
func (*ZodHostname[T]) DefaultFunc ¶ added in v0.10.5
func (z *ZodHostname[T]) DefaultFunc(fn func() string) *ZodHostname[T]
DefaultFunc sets a fallback function called when input is nil.
func (*ZodHostname[T]) Describe ¶ added in v0.5.4
func (z *ZodHostname[T]) Describe(description string) *ZodHostname[T]
Describe attaches a description to this schema via the global registry.
func (*ZodHostname[T]) Meta ¶ added in v0.10.5
func (z *ZodHostname[T]) Meta(meta core.GlobalMeta) *ZodHostname[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodHostname[T]) MustStrictParse ¶ added in v0.5.4
func (z *ZodHostname[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodHostname[T]) Nilable ¶ added in v0.5.4
func (z *ZodHostname[T]) Nilable() *ZodHostname[*string]
Nilable returns a new schema that accepts nil values.
func (*ZodHostname[T]) Nullish ¶ added in v0.6.0
func (z *ZodHostname[T]) Nullish() *ZodHostname[*string]
Nullish returns a new schema combining optional and nilable.
func (*ZodHostname[T]) Optional ¶ added in v0.5.4
func (z *ZodHostname[T]) Optional() *ZodHostname[*string]
Optional returns a new schema that accepts nil values.
func (*ZodHostname[T]) Prefault ¶ added in v0.10.5
func (z *ZodHostname[T]) Prefault(v string) *ZodHostname[T]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodHostname[T]) PrefaultFunc ¶ added in v0.10.5
func (z *ZodHostname[T]) PrefaultFunc(fn func() string) *ZodHostname[T]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodHostname[T]) RefineAny ¶ added in v0.5.7
func (z *ZodHostname[T]) RefineAny(fn func(any) bool, params ...any) *ZodHostname[T]
RefineAny adds custom validation that receives the raw value as any.
func (*ZodHostname[T]) StrictParse ¶ added in v0.5.4
func (z *ZodHostname[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodIPv4 ¶
type ZodIPv4[T StringConstraint] struct{ *ZodString[T] }
ZodIPv4 validates strings in IPv4 address format.
func CoercedIPv4 ¶ added in v0.3.0
CoercedIPv4 creates a coerced IPv4 schema that attempts string conversion.
func (*ZodIPv4[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil.
func (*ZodIPv4[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodIPv4[T]) Meta ¶ added in v0.10.5
func (z *ZodIPv4[T]) Meta(meta core.GlobalMeta) *ZodIPv4[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodIPv4[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodIPv4[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodIPv4[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodIPv4[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodIPv4[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodIPv4[T]) StrictParse ¶ added in v0.4.0
func (z *ZodIPv4[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodIPv6 ¶
type ZodIPv6[T StringConstraint] struct{ *ZodString[T] }
ZodIPv6 validates strings in IPv6 address format.
func CoercedIPv6 ¶ added in v0.3.0
CoercedIPv6 creates a coerced IPv6 schema that attempts string conversion.
func (*ZodIPv6[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil.
func (*ZodIPv6[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodIPv6[T]) Meta ¶ added in v0.10.5
func (z *ZodIPv6[T]) Meta(meta core.GlobalMeta) *ZodIPv6[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodIPv6[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodIPv6[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodIPv6[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodIPv6[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodIPv6[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodIPv6[T]) StrictParse ¶ added in v0.4.0
func (z *ZodIPv6[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodInteger ¶
type ZodInteger[T IntegerConstraint, R any] = ZodIntegerTyped[T, R]
ZodInteger is a type alias for ZodIntegerTyped providing a unified interface.
type ZodIntegerDef ¶
type ZodIntegerDef struct {
core.ZodTypeDef
}
ZodIntegerDef is the configuration for integer validation.
type ZodIntegerInternals ¶
type ZodIntegerInternals struct {
core.ZodTypeInternals
Def *ZodIntegerDef
}
ZodIntegerInternals holds the internal state of an integer validator.
type ZodIntegerTyped ¶ added in v0.3.0
type ZodIntegerTyped[T IntegerConstraint, R any] struct { // contains filtered or unexported fields }
ZodIntegerTyped is an integer validation schema with dual generic parameters.
T is the base type (int, int32, int64, etc.) and R is the 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 an 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 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.
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 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.
Example:
schema := gozod.Int().Min(0).And(gozod.Int().Max(100)) result, _ := schema.Parse(50)
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 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 converts the input to the target integer type.
func (*ZodIntegerTyped[T, R]) Default ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) Default(v int64) *ZodIntegerTyped[T, R]
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodIntegerTyped[T, R]) DefaultFunc ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) DefaultFunc(fn func() int64) *ZodIntegerTyped[T, R]
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
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.
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, ExactOptional only accepts absent keys in object fields.
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]) Internals ¶ added in v0.6.0
func (z *ZodIntegerTyped[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodIntegerTyped[T, R]) IsNilable ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodIntegerTyped[T, R]) IsOptional ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) IsOptional() bool
IsOptional reports whether 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 panics if Parse returns an error.
func (*ZodIntegerTyped[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodIntegerTyped[T, R]) MustStrictParse( input R, ctx ...*core.ParseContext, ) R
MustStrictParse panics if StrictParse returns an error.
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 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).
func (*ZodIntegerTyped[T, R]) NonOptional ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) NonOptional() *ZodIntegerTyped[T, T]
NonOptional removes the optional flag and returns a value constraint (T).
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).
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.
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 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.
Example:
schema := gozod.Int().Or(gozod.String()) result, _ := schema.Parse(42)
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.
func (*ZodIntegerTyped[T, R]) Parse ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) Parse( input any, ctx ...*core.ParseContext, ) (R, error)
Parse validates input and returns a value matching the constraint type R.
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 an untyped result for runtime scenarios.
func (*ZodIntegerTyped[T, R]) Pipe ¶ added in v0.3.0
Pipe creates a validation pipeline to another schema.
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 sets a fallback value that goes through the full validation pipeline.
func (*ZodIntegerTyped[T, R]) PrefaultFunc ¶ added in v0.3.0
func (z *ZodIntegerTyped[T, R]) PrefaultFunc(fn func() R) *ZodIntegerTyped[T, R]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
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 custom validation using the base type T.
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 using an untyped function.
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).
func (*ZodIntegerTyped[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodIntegerTyped[T, R]) StrictParse( input R, ctx ...*core.ParseContext, ) (R, error)
StrictParse validates input with compile-time type safety by requiring exact type matching.
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 that extracts int64 values.
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 (Zod v4 API compatibility).
type ZodIntersection ¶
ZodIntersection is an intersection validation schema with dual generic parameters. T is the base type (any) and R is the constraint type (any or *any).
func Intersection ¶
func Intersection(left, right any, args ...any) *ZodIntersection[any, any]
Intersection creates an intersection schema with value constraint.
func IntersectionPtr ¶ added in v0.3.0
func IntersectionPtr(left, right any, args ...any) *ZodIntersection[any, *any]
IntersectionPtr creates an intersection schema with 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 a typed intersection schema with generic constraints.
func (*ZodIntersection[T, R]) And ¶ added in v0.5.4
func (i *ZodIntersection[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
Example:
schema := gozod.String().Min(3).And(gozod.String().Max(10))
result, _ := schema.Parse("hello")
func (*ZodIntersection[T, R]) CloneFrom ¶
func (i *ZodIntersection[T, R]) CloneFrom(source any)
CloneFrom copies configuration from another schema.
func (*ZodIntersection[T, R]) Default ¶
func (i *ZodIntersection[T, R]) Default(v T) *ZodIntersection[T, R]
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodIntersection[T, R]) DefaultFunc ¶
func (i *ZodIntersection[T, R]) DefaultFunc(fn func() T) *ZodIntersection[T, R]
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodIntersection[T, R]) Describe ¶ added in v0.5.4
func (i *ZodIntersection[T, R]) Describe(description string) *ZodIntersection[T, R]
Describe registers a description in the global registry.
func (*ZodIntersection[T, R]) Internals ¶ added in v0.6.0
func (i *ZodIntersection[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodIntersection[T, R]) IsNilable ¶ added in v0.3.0
func (i *ZodIntersection[T, R]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodIntersection[T, R]) IsOptional ¶ added in v0.3.0
func (i *ZodIntersection[T, R]) IsOptional() bool
IsOptional reports whether this schema accepts undefined/missing values.
func (*ZodIntersection[T, R]) Left ¶
func (i *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 (i *ZodIntersection[T, R]) Meta(meta core.GlobalMeta) *ZodIntersection[T, R]
Meta stores metadata for this schema.
func (*ZodIntersection[T, R]) MustParse ¶
func (i *ZodIntersection[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse panics if Parse returns an error.
func (*ZodIntersection[T, R]) MustStrictParse ¶ added in v0.4.0
func (i *ZodIntersection[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse panics if StrictParse returns an error.
func (*ZodIntersection[T, R]) Nilable ¶
func (i *ZodIntersection[T, R]) Nilable() *ZodIntersection[T, *T]
Nilable returns a schema that accepts T or nil, with constraint type *T.
func (*ZodIntersection[T, R]) NonOptional ¶ added in v0.3.0
func (i *ZodIntersection[T, R]) NonOptional() *ZodIntersection[T, T]
NonOptional removes the optional flag and returns a value constraint (T).
func (*ZodIntersection[T, R]) Nullish ¶
func (i *ZodIntersection[T, R]) Nullish() *ZodIntersection[T, *T]
Nullish combines optional and nilable modifiers.
func (*ZodIntersection[T, R]) Optional ¶
func (i *ZodIntersection[T, R]) Optional() *ZodIntersection[T, *T]
Optional returns a schema that accepts T or nil, with constraint type *T.
func (*ZodIntersection[T, R]) Or ¶ added in v0.5.4
func (i *ZodIntersection[T, R]) Or(other any) *ZodUnion[any, any]
Or creates a union with another schema.
Example:
schema := gozod.String().And(gozod.String().Min(3)).Or(gozod.Int())
func (*ZodIntersection[T, R]) Parse ¶
func (i *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 (i *ZodIntersection[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
ParseAny validates input and returns an untyped result for runtime scenarios.
func (*ZodIntersection[T, R]) Prefault ¶
func (i *ZodIntersection[T, R]) Prefault(v T) *ZodIntersection[T, R]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodIntersection[T, R]) PrefaultFunc ¶
func (i *ZodIntersection[T, R]) PrefaultFunc(fn func() T) *ZodIntersection[T, R]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodIntersection[T, R]) Refine ¶
func (i *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 (i *ZodIntersection[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodIntersection[T, R]
RefineAny applies flexible validation without type conversion.
func (*ZodIntersection[T, R]) Right ¶
func (i *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 (i *ZodIntersection[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
func (*ZodIntersection[T, R]) Transform ¶
func (i *ZodIntersection[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform creates a type-safe transformation pipeline.
type ZodIntersectionDef ¶
ZodIntersectionDef is the configuration for intersection validation.
type ZodIntersectionInternals ¶
type ZodIntersectionInternals struct {
core.ZodTypeInternals
Def *ZodIntersectionDef
Left core.ZodSchema
Right core.ZodSchema
}
ZodIntersectionInternals holds the internal state of an intersection validator.
type ZodIso ¶ added in v0.3.0
type ZodIso[T IsoConstraint] struct{ *ZodString[T] }
ZodIso validates ISO 8601 formatted strings (datetime, date, time, duration).
func IsoDate ¶ added in v0.3.0
IsoDate creates a schema validating ISO 8601 date strings (YYYY-MM-DD).
func IsoDatePtr ¶ added in v0.3.0
IsoDatePtr creates a pointer ISO 8601 date schema.
func IsoDateTime ¶ added in v0.3.0
IsoDateTime creates a schema validating ISO 8601 datetime strings.
func IsoDateTimePtr ¶ added in v0.3.0
IsoDateTimePtr creates a pointer ISO 8601 datetime schema.
func IsoDateTimeTyped ¶ added in v0.3.0
func IsoDateTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]
IsoDateTimeTyped creates a typed ISO 8601 datetime schema.
func IsoDateTyped ¶ added in v0.3.0
func IsoDateTyped[T IsoConstraint](params ...any) *ZodIso[T]
IsoDateTyped creates a typed ISO 8601 date schema.
func IsoDuration ¶ added in v0.3.0
IsoDuration creates a schema validating ISO 8601 duration strings.
func IsoDurationPtr ¶ added in v0.3.0
IsoDurationPtr creates a pointer ISO 8601 duration schema.
func IsoDurationTyped ¶ added in v0.3.0
func IsoDurationTyped[T IsoConstraint](params ...any) *ZodIso[T]
IsoDurationTyped creates a typed ISO 8601 duration schema.
func IsoTime ¶ added in v0.3.0
IsoTime creates a schema validating ISO 8601 time strings (HH:MM:SS).
func IsoTimePtr ¶ added in v0.3.0
IsoTimePtr creates a pointer ISO 8601 time schema.
func IsoTimeTyped ¶ added in v0.3.0
func IsoTimeTyped[T IsoConstraint](params ...any) *ZodIso[T]
IsoTimeTyped creates a typed ISO 8601 time schema.
func IsoTyped ¶ added in v0.3.0
func IsoTyped[T IsoConstraint](params ...any) *ZodIso[T]
IsoTyped creates a typed ISO string schema.
func (*ZodIso[T]) DateTime ¶ added in v0.3.0
func (z *ZodIso[T]) DateTime(opts ...IsoDatetimeOptions) *ZodIso[T]
DateTime adds ISO 8601 datetime validation.
func (*ZodIso[T]) DefaultFunc ¶ added in v0.3.0
DefaultFunc calls fn when input is nil, bypassing validation.
func (*ZodIso[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodIso[T]) Internals ¶ added in v0.6.0
func (z *ZodIso[T]) Internals() *core.ZodTypeInternals
Internals returns the schema's internal configuration.
func (*ZodIso[T]) Max ¶ added in v0.3.0
Max validates the ISO string is <= v using lexicographic comparison.
func (*ZodIso[T]) Meta ¶ added in v0.10.5
func (z *ZodIso[T]) Meta(meta core.GlobalMeta) *ZodIso[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodIso[T]) Min ¶ added in v0.3.0
Min validates the ISO string is >= v using lexicographic comparison.
func (*ZodIso[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodIso[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodIso[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodIso[T]) Prefault ¶ added in v0.3.0
Prefault uses v when input is nil, running through full validation.
func (*ZodIso[T]) PrefaultFunc ¶ added in v0.3.0
PrefaultFunc calls fn when input is nil, running through full validation.
func (*ZodIso[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodIso[T]) StrictParse ¶ added in v0.4.0
func (z *ZodIso[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
func (*ZodIso[T]) Time ¶ added in v0.3.0
func (z *ZodIso[T]) Time(opts ...IsoTimeOptions) *ZodIso[T]
Time adds ISO 8601 time validation.
type ZodJWT ¶ added in v0.3.0
type ZodJWT[T StringConstraint] struct { *ZodString[T] }
ZodJWT validates strings in JWT (JSON Web Token) format. String modifiers (Min, Max, StartsWith, etc.) are promoted from the embedded *ZodString[T].
func JWT ¶ added in v0.3.0
JWT creates a JWT token validation schema.
JWT() - basic structure validation
JWT("error message") - with custom error message
JWT(JWTOptions{Algorithm: "HS256"}) - with algorithm constraint
JWT(JWTOptions{Algorithm: "HS256"}, "error message") - options with error message
func JWTTyped ¶ added in v0.3.0
func JWTTyped[T StringConstraint](params ...any) *ZodJWT[T]
JWTTyped creates a JWT token validation schema for a specific type.
func (*ZodJWT[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodJWT[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodJWT[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodJWT[T]) Meta ¶ added in v0.10.5
func (z *ZodJWT[T]) Meta(meta core.GlobalMeta) *ZodJWT[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodJWT[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodJWT[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodJWT[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodJWT[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodJWT[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodJWT[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodJWT[T]) StrictParse ¶ added in v0.4.0
func (z *ZodJWT[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodKSUID ¶ added in v0.3.0
type ZodKSUID[T StringConstraint] struct{ *ZodString[T] }
ZodKSUID validates strings in KSUID format.
func (*ZodKSUID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodKSUID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodKSUID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodKSUID[T]) Meta ¶ added in v0.10.5
func (z *ZodKSUID[T]) Meta(meta core.GlobalMeta) *ZodKSUID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodKSUID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodKSUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodKSUID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodKSUID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodKSUID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodKSUID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodKSUID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodKSUID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodKSUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodLazy ¶
type ZodLazy[T LazyConstraint] struct { // contains filtered or unexported fields }
ZodLazy is a lazy validation schema for recursive type definitions.
func LazyTyped ¶ added in v0.3.0
func LazyTyped[T LazyConstraint](getter func() any, params ...any) *ZodLazy[T]
LazyTyped is the underlying generic constructor for lazy schemas.
func (*ZodLazy[T]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodLazy[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodLazy[T]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodLazy[T]) Internals ¶ added in v0.6.0
func (z *ZodLazy[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodLazy[T]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodLazy[T]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 validates input and 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 with strict type matching and panics on error.
func (*ZodLazy[T]) NonOptional ¶ added in v0.3.0
NonOptional removes the Optional flag and enforces non-nil value.
func (*ZodLazy[T]) Optional ¶
Optional returns a schema that accepts nil, with constraint type *any.
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
ParseAny validates input and returns an untyped result.
func (*ZodLazy[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodLazy[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodLazy[T]) StrictParse ¶ added in v0.4.0
func (z *ZodLazy[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse requires exact type matching for compile-time safety.
type ZodLazyDef ¶
type ZodLazyDef struct {
core.ZodTypeDef
Getter func() any
}
ZodLazyDef is the configuration for lazy validation.
type ZodLazyInternals ¶
type ZodLazyInternals struct {
core.ZodTypeInternals
Def *ZodLazyDef
Getter func() any
// contains filtered or unexported fields
}
ZodLazyInternals holds the internal state of a lazy validator.
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.
func (*ZodLazyTyped[S]) Default ¶ added in v0.3.0
func (z *ZodLazyTyped[S]) Default(v any) *ZodLazyTyped[S]
Default sets a value returned when input is nil, bypassing validation.
func (*ZodLazyTyped[S]) InnerSchema ¶ added in v0.6.0
func (z *ZodLazyTyped[S]) InnerSchema() S
InnerSchema 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 validates input and panics on error.
func (*ZodLazyTyped[S]) Nilable ¶ added in v0.3.0
func (z *ZodLazyTyped[S]) Nilable() *ZodLazy[*any]
Nilable returns a schema that accepts nil.
func (*ZodLazyTyped[S]) NonOptional ¶ added in v0.3.0
func (z *ZodLazyTyped[S]) NonOptional() *ZodLazy[any]
NonOptional removes the Optional flag and enforces non-nil value.
func (*ZodLazyTyped[S]) Optional ¶ added in v0.3.0
func (z *ZodLazyTyped[S]) Optional() *ZodLazy[*any]
Optional returns a schema that accepts nil.
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 adds a custom validation function.
type ZodLiteral ¶
type ZodLiteral[T comparable, R any] struct { // contains filtered or unexported fields }
ZodLiteral represents a literal validation schema for exact value matching.
func Literal ¶
func Literal[T comparable](value T, params ...any) *ZodLiteral[T, T]
Literal creates a literal schema for a single value with type inference.
func LiteralOf ¶ added in v0.3.0
func LiteralOf[T comparable](values []T, params ...any) *ZodLiteral[T, T]
LiteralOf creates a multi-value literal schema with type inference.
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]
LiteralTyped creates a literal schema with explicit type parameters.
func (*ZodLiteral[T, R]) Contains ¶ added in v0.3.0
func (z *ZodLiteral[T, R]) Contains(v T) bool
Contains reports whether v 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 returned when input is nil, bypassing validation.
func (*ZodLiteral[T, R]) DefaultFunc ¶
func (z *ZodLiteral[T, R]) DefaultFunc(fn func() T) *ZodLiteral[T, R]
DefaultFunc sets a factory function that provides the default value when input is nil.
func (*ZodLiteral[T, R]) Describe ¶ added in v0.6.0
func (z *ZodLiteral[T, R]) Describe(description string) *ZodLiteral[T, R]
Describe registers a description in the global registry.
func (*ZodLiteral[T, R]) Internals ¶ added in v0.6.0
func (z *ZodLiteral[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodLiteral[T, R]) IsNilable ¶ added in v0.3.0
func (z *ZodLiteral[T, R]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodLiteral[T, R]) IsOptional ¶ added in v0.3.0
func (z *ZodLiteral[T, R]) IsOptional() bool
IsOptional reports whether this schema accepts undefined/missing values.
func (*ZodLiteral[T, R]) Meta ¶ added in v0.6.0
func (z *ZodLiteral[T, R]) Meta(meta core.GlobalMeta) *ZodLiteral[T, R]
Meta stores metadata for this literal schema.
func (*ZodLiteral[T, R]) MustParse ¶
func (z *ZodLiteral[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on error.
func (*ZodLiteral[T, R]) MustParseAny ¶ added in v0.3.1
func (z *ZodLiteral[T, R]) MustParseAny(input any, ctx ...*core.ParseContext) any
MustParseAny validates input and panics on error, returning an untyped result.
func (*ZodLiteral[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodLiteral[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
MustStrictParse validates input with strict type matching and panics on error.
func (*ZodLiteral[T, R]) Nilable ¶
func (z *ZodLiteral[T, R]) Nilable() *ZodLiteral[T, *T]
Nilable returns a schema that accepts nil, with constraint type *T.
func (*ZodLiteral[T, R]) Nullish ¶
func (z *ZodLiteral[T, R]) Nullish() *ZodLiteral[T, *T]
Nullish combines optional and nilable modifiers for maximum flexibility.
func (*ZodLiteral[T, R]) Optional ¶
func (z *ZodLiteral[T, R]) Optional() *ZodLiteral[T, *T]
Optional returns a schema that accepts nil, with constraint type *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.
func (*ZodLiteral[T, R]) ParseAny ¶ added in v0.3.0
func (z *ZodLiteral[T, R]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
ParseAny validates input and returns an untyped result for runtime scenarios.
func (*ZodLiteral[T, R]) Prefault ¶
func (z *ZodLiteral[T, R]) Prefault(v T) *ZodLiteral[T, R]
Prefault sets a prefault value that goes through full parsing when input is nil.
func (*ZodLiteral[T, R]) PrefaultFunc ¶
func (z *ZodLiteral[T, R]) PrefaultFunc(fn func() T) *ZodLiteral[T, R]
PrefaultFunc sets a factory function that provides the prefault value through full parsing.
func (*ZodLiteral[T, R]) Refine ¶
func (z *ZodLiteral[T, R]) Refine(fn func(T) bool, params ...any) *ZodLiteral[T, R]
Refine adds a typed custom validation function.
func (*ZodLiteral[T, R]) RefineAny ¶
func (z *ZodLiteral[T, R]) RefineAny(fn func(any) bool, params ...any) *ZodLiteral[T, R]
RefineAny adds a flexible custom validation function accepting any input.
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 single literal value. Panics if the schema has multiple values.
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 configuration for a literal schema.
type ZodLiteralInternals ¶
type ZodLiteralInternals[T comparable] struct { core.ZodTypeInternals Def *ZodLiteralDef[T] }
ZodLiteralInternals contains literal validator internal state.
type ZodMAC ¶ added in v0.5.4
type ZodMAC[T StringConstraint] struct{ *ZodString[T] }
ZodMAC validates strings in MAC address format.
func CoercedMAC ¶ added in v0.6.0
CoercedMAC creates a coerced MAC schema that attempts string conversion.
func MAC ¶ added in v0.5.4
MAC creates a MAC address validation schema. Accepts optional delimiter string as first parameter (default: any standard delimiter).
func MACPtr ¶ added in v0.5.4
MACPtr creates a pointer MAC address validation schema. Accepts optional delimiter string as first parameter (default: any standard delimiter).
func MACTyped ¶ added in v0.5.4
func MACTyped[T StringConstraint](params ...any) *ZodMAC[T]
MACTyped creates a MAC address validation schema with the given type constraint. Accepts optional delimiter string as first parameter (default: any standard delimiter).
func MACWithDelimiter ¶ added in v0.5.4
MACWithDelimiter creates a MAC address validation schema with a specific delimiter.
func (*ZodMAC[T]) Default ¶ added in v0.5.4
Default sets a fallback value returned when input is nil.
func (*ZodMAC[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodMAC[T]) Describe ¶ added in v0.5.4
Describe attaches a description to this schema via the global registry.
func (*ZodMAC[T]) Meta ¶ added in v0.10.5
func (z *ZodMAC[T]) Meta(meta core.GlobalMeta) *ZodMAC[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodMAC[T]) MustStrictParse ¶ added in v0.5.4
func (z *ZodMAC[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodMAC[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodMAC[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodMAC[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodMAC[T]) RefineAny ¶ added in v0.5.7
RefineAny adds custom validation that receives the raw value as any.
func (*ZodMAC[T]) StrictParse ¶ added in v0.5.4
func (z *ZodMAC[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodMap ¶
ZodMap is a type-safe map validation schema. T is the base type, R is the constraint type (value or pointer).
func MapTyped ¶ added in v0.3.0
MapTyped creates a typed map schema with explicit 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.
func (*ZodMap[T, R]) CloneFrom ¶
CloneFrom copies configuration from another schema of the same type.
func (*ZodMap[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodMap[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodMap[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodMap[T, R]) Internals ¶ added in v0.6.0
func (z *ZodMap[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodMap[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodMap[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
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]) MustParse ¶
func (z *ZodMap[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on error.
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 type safety and panics on error.
func (*ZodMap[T, R]) NonEmpty ¶ added in v0.5.4
NonEmpty ensures the map has at least one entry. Equivalent to Min(1).
func (*ZodMap[T, R]) NonOptional ¶ added in v0.3.0
NonOptional removes the Optional flag and returns base constraint type.
func (*ZodMap[T, R]) Optional ¶
Optional returns a schema that accepts nil, with constraint type *T.
func (*ZodMap[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the value while preserving the original type.
func (*ZodMap[T, R]) Parse ¶
func (z *ZodMap[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input using map-specific parsing logic.
func (*ZodMap[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodMap[T, R]) Pipe ¶
Pipe creates a pipeline that passes the parsed result to a target schema.
func (*ZodMap[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodMap[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
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 to the parsed map value.
type ZodMapDef ¶
type ZodMapDef struct {
core.ZodTypeDef
KeyType any
ValueType any
}
ZodMapDef is the configuration for a map schema.
type ZodMapInternals ¶
type ZodMapInternals struct {
core.ZodTypeInternals
Def *ZodMapDef
KeyType any
ValueType any
}
ZodMapInternals holds the internal state of a map validator.
type ZodNanoID ¶ added in v0.3.0
type ZodNanoID[T StringConstraint] struct{ *ZodString[T] }
ZodNanoID validates strings in NanoID format.
func (*ZodNanoID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodNanoID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodNanoID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodNanoID[T]) Meta ¶ added in v0.10.5
func (z *ZodNanoID[T]) Meta(meta core.GlobalMeta) *ZodNanoID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodNanoID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodNanoID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodNanoID[T]) Nilable ¶ added in v0.6.0
Nilable returns a new schema that accepts nil values.
func (*ZodNanoID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodNanoID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodNanoID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodNanoID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodNanoID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodNanoID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodNanoID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodNever ¶
ZodNever represents a validation schema that always rejects input. T is the base type and R is the constraint type (may be a pointer for modifiers like Optional/Nilable).
func Never ¶
Never creates a never schema that always rejects input.
Usage:
Never() // no parameters
Never("custom error") // string shorthand
Never(SchemaParams{...}) // full parameters
func NeverTyped ¶ added in v0.3.0
NeverTyped creates a typed never schema with explicit generic constraints.
func (*ZodNever[T, R]) CloneFrom ¶
CloneFrom copies the configuration from another schema of the same type.
func (*ZodNever[T, R]) Default ¶ added in v0.3.0
Default sets a default value that is returned when the input is nil. The default value bypasses validation (short-circuit behavior).
func (*ZodNever[T, R]) DefaultFunc ¶ added in v0.3.0
DefaultFunc sets a function that provides the default value when the input is nil. The default value bypasses validation (short-circuit behavior).
func (*ZodNever[T, R]) Describe ¶ added in v0.5.4
Describe registers a description for this schema in the global registry.
func (*ZodNever[T, R]) Internals ¶ added in v0.6.0
func (z *ZodNever[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodNever[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodNever[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts 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 schema in the global registry.
func (*ZodNever[T, R]) MustParse ¶
func (z *ZodNever[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates the input and panics on failure.
func (*ZodNever[T, R]) MustParseAny ¶ added in v0.6.0
func (z *ZodNever[T, R]) MustParseAny(input any, ctx ...*core.ParseContext) any
MustParseAny validates the input 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 requires exact type matching and panics on failure.
func (*ZodNever[T, R]) Nullish ¶
Nullish returns a pointer constraint that accepts both nil and missing values.
func (*ZodNever[T, R]) Optional ¶
Optional returns a pointer constraint that accepts missing values.
func (*ZodNever[T, R]) Parse ¶
func (z *ZodNever[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates the input and always rejects non-nil values.
func (*ZodNever[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates the input and returns any type.
func (*ZodNever[T, R]) Prefault ¶ added in v0.3.0
Prefault sets a fallback value that is used when the input is nil. Unlike Default, the prefault value goes through the full parsing pipeline.
func (*ZodNever[T, R]) PrefaultFunc ¶ added in v0.3.0
PrefaultFunc sets a function that provides the fallback value when the input is nil. Unlike DefaultFunc, the prefault value goes through the full parsing pipeline.
func (*ZodNever[T, R]) Refine ¶
Refine adds a custom validation function that operates on the constraint type R.
func (*ZodNever[T, R]) RefineAny ¶
RefineAny adds a custom validation function that operates on 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 requires exact type matching for compile-time type safety.
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 to the parsed value.
type ZodNeverDef ¶
type ZodNeverDef struct {
core.ZodTypeDef
}
ZodNeverDef defines the configuration for never validation.
type ZodNeverInternals ¶
type ZodNeverInternals struct {
core.ZodTypeInternals
Def *ZodNeverDef
}
ZodNeverInternals contains the internal state for never validators.
type ZodNil ¶
ZodNil is a type-safe nil validation schema. T is the base type and R is the constraint type (may be a pointer for modifiers like Optional/Nilable).
func Nil ¶
Nil creates a nil schema that only accepts nil values.
Usage:
Nil() // no parameters
Nil("custom error") // string shorthand
Nil(SchemaParams{...}) // full parameters
func (*ZodNil[T, R]) And ¶ added in v0.6.0
func (z *ZodNil[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodNil[T, R]) Check ¶
func (z *ZodNil[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodNil[T, R]
Check adds a custom validation function that can push multiple issues.
func (*ZodNil[T, R]) CloneFrom ¶
CloneFrom copies configuration from another schema of the same type.
func (*ZodNil[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodNil[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodNil[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodNil[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodNil[T, R]) Internals ¶ added in v0.6.0
func (z *ZodNil[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodNil[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodNil[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts missing values.
func (*ZodNil[T, R]) Meta ¶ added in v0.3.1
func (z *ZodNil[T, R]) Meta(meta core.GlobalMeta) *ZodNil[T, R]
Meta stores metadata in the global registry.
func (*ZodNil[T, R]) MustParse ¶
func (z *ZodNil[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse panics on validation failure.
func (*ZodNil[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodNil[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodNil[T, R]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodNil[T, R]) NonOptional ¶ added in v0.6.0
NonOptional removes the optional flag, returning a base constraint.
func (*ZodNil[T, R]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodNil[T, R]) Overwrite ¶ added in v0.6.0
Overwrite transforms the input value while preserving the original type.
func (*ZodNil[T, R]) Parse ¶
func (z *ZodNil[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns a value matching the constraint type R.
func (*ZodNil[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodNil[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodNil[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodNil[T, R]) Refine ¶
Refine applies a custom validation function matching the schema's output type R.
func (*ZodNil[T, R]) RefineAny ¶
RefineAny applies a custom validation function that receives the raw value.
func (*ZodNil[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodNil[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
func (*ZodNil[T, R]) Transform ¶
func (z *ZodNil[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform applies a transformation function to the parsed value.
type ZodNilDef ¶
type ZodNilDef struct {
core.ZodTypeDef
}
ZodNilDef holds the configuration for nil validation.
type ZodNilInternals ¶
type ZodNilInternals struct {
core.ZodTypeInternals
Def *ZodNilDef
}
ZodNilInternals contains the internal state of a nil validator.
type ZodObject ¶
ZodObject represents a type-safe object validation schema. T is the base type, R is the constraint type (value or pointer).
func LooseObject ¶
LooseObject creates a loose object schema that allows unknown keys.
func LooseObjectPtr ¶ added in v0.3.0
func LooseObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]
LooseObjectPtr creates a loose object schema with pointer constraint.
func ObjectTyped ¶ added in v0.3.0
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 a strict object schema that rejects unknown keys.
func StrictObjectPtr ¶ added in v0.3.0
func StrictObjectPtr(shape core.ObjectSchema, params ...any) *ZodObject[map[string]any, *map[string]any]
StrictObjectPtr creates a 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.
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.
func (*ZodObject[T, R]) Default ¶
Default sets a default value returned when input is nil, bypassing validation.
func (*ZodObject[T, R]) DefaultFunc ¶
DefaultFunc sets a factory function that provides the default value when input is nil.
func (*ZodObject[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
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 an error if the schema has refinements and augmentation overlaps existing keys.
func (*ZodObject[T, R]) Internals ¶ added in v0.6.0
func (z *ZodObject[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodObject[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodObject[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
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]) MustParse ¶
func (z *ZodObject[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and 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 error.
func (*ZodObject[T, R]) Nilable ¶
Nilable returns a schema that accepts nil, with constraint type *T.
func (*ZodObject[T, R]) NonOptional ¶ added in v0.3.0
NonOptional removes the optional flag and returns base constraint type.
func (*ZodObject[T, R]) Omit ¶
Omit creates a new object excluding the specified keys. Returns an error if any key does not exist or the schema contains refinements.
func (*ZodObject[T, R]) Optional ¶
Optional returns a schema that accepts nil, with constraint type *T.
func (*ZodObject[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the value while preserving the original 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
ParseAny validates input and returns an untyped result for runtime scenarios.
func (*ZodObject[T, R]) Partial ¶
Partial makes all fields optional, or specific fields if keys are provided.
func (*ZodObject[T, R]) Passthrough ¶
Passthrough sets passthrough mode (allows unknown keys).
func (*ZodObject[T, R]) Pick ¶
Pick creates a new object with only the specified keys. Returns an error if any key does not exist or the schema contains refinements.
func (*ZodObject[T, R]) Prefault ¶
Prefault sets a prefault value that goes through the full parsing pipeline when input is nil.
func (*ZodObject[T, R]) PrefaultFunc ¶
PrefaultFunc sets a factory function that provides the prefault value through the full parsing pipeline.
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 ¶
Refine applies type-safe validation using constraint type. Schemas with refinements cannot use Pick/Omit.
func (*ZodObject[T, R]) RefineAny ¶
RefineAny provides flexible validation without type conversion. Schemas with refinements cannot use Pick/Omit.
func (*ZodObject[T, R]) Required ¶
Required makes all fields required, or specific fields if provided.
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 without checking refinements.
func (*ZodObject[T, R]) Shape ¶
func (z *ZodObject[T, R]) Shape() core.ObjectSchema
Shape returns the object shape (field schemas).
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.
func (*ZodObject[T, R]) Transform ¶
func (z *ZodObject[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform applies a transformation function to the parsed object value.
func (*ZodObject[T, R]) UnknownKeys ¶ added in v0.6.0
func (z *ZodObject[T, R]) UnknownKeys() ObjectMode
UnknownKeys returns the unknown keys handling mode.
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.
func (*ZodObject[T, R]) WithCatchall ¶ added in v0.6.0
WithCatchall sets a schema for validating unknown keys.
func (*ZodObject[T, R]) WithFieldNameTag ¶ added in v0.11.6
WithFieldNameTag returns a new schema that resolves struct field names using the named struct tag (e.g. "yaml", "toml") instead of the default "json" when a struct value is coerced to an object.
type ZodObjectDef ¶
type ZodObjectDef struct {
core.ZodTypeDef
// Shape maps field names to field schemas.
Shape core.ObjectSchema
// Catchall validates unknown keys when passthrough behavior is enabled.
Catchall core.ZodSchema
// UnknownKeys controls how unknown keys are handled.
UnknownKeys ObjectMode
}
ZodObjectDef defines the configuration for an object schema.
type ZodObjectInternals ¶
type ZodObjectInternals struct {
core.ZodTypeInternals
// Def points to the schema definition.
Def *ZodObjectDef
// Shape maps field names to field schemas.
Shape core.ObjectSchema
// Catchall validates unknown keys when passthrough behavior is enabled.
Catchall core.ZodSchema
// UnknownKeys controls how unknown keys are handled.
UnknownKeys ObjectMode
// IsPartial reports whether omitted fields are allowed.
IsPartial bool
// PartialExceptions marks fields that remain required in partial mode.
PartialExceptions map[string]bool
// HasUserRefinements reports whether user-defined refinements are attached.
HasUserRefinements bool
// FieldNameTag is the struct tag used for field names (default "json").
FieldNameTag string
}
ZodObjectInternals contains object validator internal state.
type ZodRecord ¶
ZodRecord represents a type-safe record validation schema. T is the base type, R is the constraint type (value or pointer).
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 a 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.
func PartialRecordPtr ¶ added in v0.3.1
func PartialRecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]
PartialRecordPtr creates a partial record schema returning a pointer constraint.
func Record ¶
func Record(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, map[string]any]
Record creates a record schema with key and value schemas.
func RecordPtr ¶ added in v0.3.0
func RecordPtr(keySchema, valueSchema any, paramArgs ...any) *ZodRecord[map[string]any, *map[string]any]
RecordPtr creates a record schema returning a pointer constraint.
func RecordTyped ¶ added in v0.3.0
RecordTyped creates a 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.
func (*ZodRecord[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodRecord[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodRecord[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodRecord[T, R]) Internals ¶ added in v0.6.0
func (z *ZodRecord[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodRecord[T, R]) IsLoose ¶ added in v0.5.4
IsLoose reports whether non-matching keys pass through unchanged.
func (*ZodRecord[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodRecord[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
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]) MustParse ¶
func (z *ZodRecord[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on error.
func (*ZodRecord[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodRecord[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse validates input with type safety and panics on error.
func (*ZodRecord[T, R]) NonOptional ¶ added in v0.3.0
NonOptional removes Optional flag and enforces record presence.
func (*ZodRecord[T, R]) Optional ¶
Optional creates an optional record schema that returns a pointer constraint.
func (*ZodRecord[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the input value while preserving the original 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
ParseAny validates input and returns an untyped result.
func (*ZodRecord[T, R]) Partial ¶ added in v0.5.5
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]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodRecord[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodRecord[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodRecord[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
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 to the parsed record value.
type ZodRecordDef ¶
type ZodRecordDef struct {
core.ZodTypeDef
KeyType any
ValueType any
}
ZodRecordDef defines the configuration for a record schema.
type ZodRecordInternals ¶
type ZodRecordInternals struct {
core.ZodTypeInternals
Def *ZodRecordDef
KeyType any
ValueType any
Loose bool
}
ZodRecordInternals contains record validator internal state.
type ZodSchemaType ¶ added in v0.3.0
type ZodSchemaType interface {
Internals() *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 is a type-safe set validation schema. T is the element type (must be comparable). R is the constraint type (value or pointer).
func Set ¶ added in v0.5.5
func Set[T comparable](valueSchema any, paramArgs ...any) *ZodSet[T, map[T]struct{}]
Set creates a set schema with element validation.
func SetPtr ¶ added in v0.5.5
func SetPtr[T comparable](valueSchema any, paramArgs ...any) *ZodSet[T, *map[T]struct{}]
SetPtr creates a set schema returning a pointer constraint.
func SetTyped ¶ added in v0.5.5
func SetTyped[T comparable, R any](valueSchema any, paramArgs ...any) *ZodSet[T, R]
SetTyped creates a typed set schema with explicit generic constraints.
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.
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 that can report multiple issues.
func (*ZodSet[T, R]) CloneFrom ¶ added in v0.5.5
CloneFrom copies configuration from another schema of the same type.
func (*ZodSet[T, R]) Default ¶ added in v0.5.5
Default sets a fallback value returned when input is nil (short-circuits validation). The default value bypasses validation.
func (*ZodSet[T, R]) DefaultFunc ¶ added in v0.5.5
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodSet[T, R]) Describe ¶ added in v0.5.5
Describe registers a description in the global registry.
func (*ZodSet[T, R]) Internals ¶ added in v0.6.0
func (z *ZodSet[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodSet[T, R]) IsNilable ¶ added in v0.5.5
IsNilable reports whether this schema accepts nil values.
func (*ZodSet[T, R]) IsOptional ¶ added in v0.5.5
IsOptional reports whether this schema accepts undefined or missing values.
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.
func (*ZodSet[T, R]) MustParse ¶ added in v0.5.5
func (z *ZodSet[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on error.
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 type safety and panics on error.
func (*ZodSet[T, R]) Nilable ¶ added in v0.5.5
Nilable returns a schema that accepts nil. The constraint type becomes *map[T]struct{}.
func (*ZodSet[T, R]) NonEmpty ¶ added in v0.5.5
NonEmpty ensures the set has at least one element. This is equivalent to Min(1).
func (*ZodSet[T, R]) NonOptional ¶ added in v0.5.5
NonOptional removes the Optional flag and returns base constraint type.
func (*ZodSet[T, R]) Optional ¶ added in v0.5.5
Optional returns a schema that accepts nil. The constraint type becomes *map[T]struct{}.
func (*ZodSet[T, R]) Overwrite ¶ added in v0.5.5
Overwrite transforms the value while preserving the original 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.
func (*ZodSet[T, R]) ParseAny ¶ added in v0.5.5
ParseAny validates input and returns an untyped result.
func (*ZodSet[T, R]) Pipe ¶ added in v0.5.5
Pipe creates a pipeline that passes the parsed result to a target schema.
func (*ZodSet[T, R]) Prefault ¶ added in v0.5.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodSet[T, R]) PrefaultFunc ¶ added in v0.5.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline. The prefault value goes through full validation.
func (*ZodSet[T, R]) RefineAny ¶ added in v0.5.5
RefineAny adds a custom validation function accepting any input.
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 validates input with compile-time type safety.
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 to the parsed set value.
type ZodSetDef ¶ added in v0.5.5
type ZodSetDef struct {
core.ZodTypeDef
ValueType any
}
ZodSetDef defines the configuration for a set schema.
type ZodSetInternals ¶ added in v0.5.5
type ZodSetInternals[T comparable] struct { core.ZodTypeInternals Def *ZodSetDef ValueType any }
ZodSetInternals holds the internal state of a set validator.
type ZodSlice ¶
ZodSlice is a type-safe slice validation schema. T is the element type, R is the constraint type (value or pointer).
func SliceTyped ¶ added in v0.3.0
SliceTyped creates a slice schema with an explicit constraint type.
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.
func (*ZodSlice[T, R]) Check ¶
func (z *ZodSlice[T, R]) Check( fn func(R, *core.ParsePayload), params ...any, ) *ZodSlice[T, R]
Check adds a custom validation function that can report multiple issues.
func (*ZodSlice[T, R]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation). Short-circuits validation and returns the default immediately.
func (*ZodSlice[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodSlice[T, R]) Describe ¶ added in v0.5.4
Describe sets a description for this schema in the global registry.
func (*ZodSlice[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodSlice[T, R]) Internals ¶ added in v0.6.0
func (z *ZodSlice[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state for framework usage.
func (*ZodSlice[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodSlice[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
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]) MustParse ¶
func (z *ZodSlice[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse validates input and panics on error.
func (*ZodSlice[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodSlice[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
MustStrictParse validates input with type safety and panics on error.
func (*ZodSlice[T, R]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodSlice[T, R]) NonOptional ¶ added in v0.3.0
NonOptional enforces non-nil value constraint.
func (*ZodSlice[T, R]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodSlice[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the slice value while preserving the original type.
func (*ZodSlice[T, R]) Parse ¶
func (z *ZodSlice[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns the parsed slice value.
func (*ZodSlice[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodSlice[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodSlice[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodSlice[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodSlice[T, R]) StrictParse(input R, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
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 to the parsed slice value.
type ZodSliceDef ¶
type ZodSliceDef struct {
core.ZodTypeDef
Element any
}
ZodSliceDef defines the configuration for a slice schema.
type ZodSliceInternals ¶
type ZodSliceInternals[T any] struct { core.ZodTypeInternals Def *ZodSliceDef Element any }
ZodSliceInternals contains the internal state for a slice schema.
type ZodString ¶
type ZodString[T StringConstraint] struct { // contains filtered or unexported fields }
ZodString is a type-safe string validation schema.
func CoercedString ¶ added in v0.2.1
CoercedString creates a new string schema with coercion enabled.
func CoercedStringPtr ¶ added in v0.3.0
CoercedStringPtr creates a new string schema with pointer type and coercion.
func StringTyped ¶ added in v0.3.0
func StringTyped[T StringConstraint](params ...any) *ZodString[T]
StringTyped creates a new string schema with a specific constraint 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.
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.
func (*ZodString[T]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodString[T]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodString[T]) Describe ¶ added in v0.5.3
Describe attaches a description to this schema via the global registry.
func (*ZodString[T]) ExactOptional ¶ added in v0.5.4
ExactOptional returns a new schema that accepts absent keys but rejects explicit nil. Unlike Optional, it only accepts absent keys in object fields.
func (*ZodString[T]) Internals ¶ added in v0.6.0
func (z *ZodString[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodString[T]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodString[T]) IsOptional ¶ added in v0.3.0
IsOptional reports whether this schema accepts undefined/missing values.
func (*ZodString[T]) JWT ¶
JWT adds JWT token format validation.
Accepts an optional algorithm string ("HS256", "RS256", etc.) or validate.JWTOptions.
JWT() // standard format
JWT("HS256") // require specific algorithm
JWT(validate.JWTOptions{Algorithm: "RS256"}) // full options
func (*ZodString[T]) Lowercase ¶ added in v0.5.5
Lowercase validates that the string contains no uppercase letters.
func (*ZodString[T]) MAC ¶ added in v0.5.3
MAC adds MAC address format validation.
Accepts an optional delimiter string (":", "-", ".") or validate.MACOptions. Without arguments, defaults to colon delimiter.
MAC() // default ":"
MAC("-") // dash delimiter
MAC(validate.MACOptions{Delimiter: "."}) // full options
func (*ZodString[T]) Meta ¶ added in v0.3.1
func (z *ZodString[T]) Meta(meta core.GlobalMeta) *ZodString[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodString[T]) MustParse ¶
func (z *ZodString[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse validates input and panics on failure.
func (*ZodString[T]) MustParseAny ¶ added in v0.3.1
func (z *ZodString[T]) MustParseAny(input any, ctx ...*core.ParseContext) any
MustParseAny validates input 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 requires exact type T and panics on failure.
func (*ZodString[T]) Nilable ¶
Nilable returns a new schema that accepts nil values, with *string constraint.
func (*ZodString[T]) NonOptional ¶ added in v0.3.0
NonOptional removes the optional flag and returns a required string schema.
func (*ZodString[T]) Normalize ¶ added in v0.5.5
Normalize transforms the string using Unicode normalization. Supported forms: "NFC" (default), "NFD", "NFKC", "NFKD".
func (*ZodString[T]) Nullish ¶
Nullish returns a new schema that combines optional and nilable modifiers.
func (*ZodString[T]) Optional ¶
Optional returns a new schema that accepts nil, with *string output.
func (*ZodString[T]) Overwrite ¶ added in v0.3.0
Overwrite applies a same-type transformation to the validated string.
func (*ZodString[T]) Parse ¶
func (z *ZodString[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value of type T.
func (*ZodString[T]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns any for runtime interface usage.
func (*ZodString[T]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodString[T]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodString[T]) Refine ¶
Refine applies a custom validation function matching the schema's output type T.
func (*ZodString[T]) RefineAny ¶
RefineAny adds custom validation that receives the raw value as any.
func (*ZodString[T]) RegexString ¶ added in v0.3.0
RegexString adds custom regex validation using a string pattern.
func (*ZodString[T]) Slugify ¶ added in v0.5.3
Slugify transforms the string to a URL-friendly slug.
func (*ZodString[T]) StartsWith ¶
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 requires exact type T for compile-time type safety.
func (*ZodString[T]) ToLowerCase ¶
ToLowerCase transforms the string to lower case.
func (*ZodString[T]) ToUpperCase ¶
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.
type ZodStringBool ¶
type ZodStringBool[T StringBoolConstraint] struct { // contains filtered or unexported fields }
ZodStringBool is a type-safe string-to-boolean validation schema.
func CoercedStringBool ¶ added in v0.3.0
func CoercedStringBool(params ...any) *ZodStringBool[bool]
CoercedStringBool creates a coerced string-to-bool schema.
func CoercedStringBoolPtr ¶ added in v0.3.0
func CoercedStringBoolPtr(params ...any) *ZodStringBool[*bool]
CoercedStringBoolPtr creates a coerced string-to-*bool schema.
func StringBool ¶
func StringBool(params ...any) *ZodStringBool[bool]
StringBool creates a string-to-bool validation schema.
func StringBoolPtr ¶ added in v0.3.0
func StringBoolPtr(params ...any) *ZodStringBool[*bool]
StringBoolPtr creates a string-to-*bool validation schema.
func StringBoolTyped ¶ added in v0.3.0
func StringBoolTyped[T StringBoolConstraint](params ...any) *ZodStringBool[T]
StringBoolTyped is the generic constructor for string-boolean schemas.
func (*ZodStringBool[T]) And ¶ added in v0.6.0
func (z *ZodStringBool[T]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodStringBool[T]) Check ¶ added in v0.6.0
func (z *ZodStringBool[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodStringBool[T]
Check adds a custom validation function that can push multiple issues.
func (*ZodStringBool[T]) CloneFrom ¶ added in v0.3.0
func (z *ZodStringBool[T]) CloneFrom(source any)
CloneFrom copies configuration from another schema of the same type.
func (*ZodStringBool[T]) Coerce ¶
func (z *ZodStringBool[T]) Coerce(input any) (any, bool)
Coerce converts input to a recognized truthy/falsy string.
func (*ZodStringBool[T]) Default ¶
func (z *ZodStringBool[T]) Default(v bool) *ZodStringBool[T]
Default sets a fallback value returned when input is nil (short-circuits).
func (*ZodStringBool[T]) DefaultFunc ¶
func (z *ZodStringBool[T]) DefaultFunc(fn func() bool) *ZodStringBool[T]
DefaultFunc sets a fallback function called when input is nil (short-circuits).
func (*ZodStringBool[T]) Describe ¶ added in v0.5.4
func (z *ZodStringBool[T]) Describe(desc string) *ZodStringBool[T]
Describe registers a description in the global registry.
func (*ZodStringBool[T]) ExactOptional ¶ added in v0.6.0
func (z *ZodStringBool[T]) ExactOptional() *ZodStringBool[T]
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodStringBool[T]) Internals ¶ added in v0.6.0
func (z *ZodStringBool[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodStringBool[T]) IsNilable ¶ added in v0.3.0
func (z *ZodStringBool[T]) IsNilable() bool
IsNilable reports whether this schema accepts nil values.
func (*ZodStringBool[T]) IsOptional ¶ added in v0.3.0
func (z *ZodStringBool[T]) IsOptional() bool
IsOptional reports whether 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 in the global registry.
func (*ZodStringBool[T]) MustParse ¶
func (z *ZodStringBool[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse panics on validation failure.
func (*ZodStringBool[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodStringBool[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodStringBool[T]) Nilable ¶
func (z *ZodStringBool[T]) Nilable() *ZodStringBool[*bool]
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodStringBool[T]) NonOptional ¶ added in v0.6.0
func (z *ZodStringBool[T]) NonOptional() *ZodStringBool[bool]
NonOptional removes the optional flag, returning a bool constraint.
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 returns a schema that accepts nil values with pointer constraint.
func (*ZodStringBool[T]) Or ¶ added in v0.6.0
func (z *ZodStringBool[T]) Or(other any) *ZodUnion[any, any]
Or creates a union with another schema.
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.
func (*ZodStringBool[T]) Parse ¶
func (z *ZodStringBool[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value matching the generic type T.
func (*ZodStringBool[T]) ParseAny ¶ added in v0.3.0
func (z *ZodStringBool[T]) ParseAny(input any, ctx ...*core.ParseContext) (any, error)
ParseAny validates input and returns an untyped result.
func (*ZodStringBool[T]) Prefault ¶
func (z *ZodStringBool[T]) Prefault(v string) *ZodStringBool[T]
Prefault sets a fallback value that goes through the full validation pipeline. Accepts string input per Zod v4 semantics for StringBool.
func (*ZodStringBool[T]) PrefaultFunc ¶
func (z *ZodStringBool[T]) PrefaultFunc(fn func() string) *ZodStringBool[T]
PrefaultFunc sets a fallback function that goes through the full validation pipeline. Returns string per Zod v4 semantics for StringBool.
func (*ZodStringBool[T]) Refine ¶
func (z *ZodStringBool[T]) Refine(fn func(T) bool, params ...any) *ZodStringBool[T]
Refine applies a custom validation function matching the schema's output type T.
func (*ZodStringBool[T]) RefineAny ¶
func (z *ZodStringBool[T]) RefineAny(fn func(any) bool, params ...any) *ZodStringBool[T]
RefineAny applies a custom validation function that receives the raw value.
func (*ZodStringBool[T]) StrictParse ¶ added in v0.4.0
func (z *ZodStringBool[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
func (*ZodStringBool[T]) Transform ¶
func (z *ZodStringBool[T]) Transform(fn func(bool, *core.RefinementContext) (any, error)) *core.ZodTransform[T, any]
Transform applies a transformation function to the parsed value.
func (*ZodStringBool[T]) With ¶ added in v0.6.0
func (z *ZodStringBool[T]) With(fn func(value T, payload *core.ParsePayload), params ...any) *ZodStringBool[T]
With is an alias for Check (Zod v4 API compatibility).
type ZodStringBoolDef ¶
type ZodStringBoolDef struct {
core.ZodTypeDef
Truthy []string
Falsy []string
Case string
Custom bool
}
ZodStringBoolDef holds the configuration for string-boolean validation.
type ZodStringBoolInternals ¶
type ZodStringBoolInternals struct {
core.ZodTypeInternals
Def *ZodStringBoolDef
Truthy map[string]struct{}
Falsy map[string]struct{}
}
ZodStringBoolInternals contains the internal state of a string-boolean validator.
type ZodStringDef ¶
type ZodStringDef struct {
core.ZodTypeDef
}
ZodStringDef holds the configuration for a string schema.
type ZodStringInternals ¶
type ZodStringInternals struct {
core.ZodTypeInternals
Def *ZodStringDef
}
ZodStringInternals holds string validator internal state.
type ZodStruct ¶
ZodStruct represents a type-safe struct validation schema.
func FromStruct ¶ added in v0.5.0
func FromStruct[T any](opts ...FromStructOption) *ZodStruct[T, T]
FromStruct builds a struct schema from tags on T.
func FromStructPtr ¶ added in v0.5.0
func FromStructPtr[T any](opts ...FromStructOption) *ZodStruct[T, *T]
FromStructPtr builds a struct schema for *T from tags on T.
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]) Default ¶
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodStruct[T, R]) DefaultFunc ¶
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodStruct[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodStruct[T, R]) Extend ¶
func (z *ZodStruct[T, R]) Extend(augmentation core.StructSchema, params ...any) *ZodStruct[T, R]
Extend returns a schema with additional field schemas.
func (*ZodStruct[T, R]) Internals ¶ added in v0.6.0
func (z *ZodStruct[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodStruct[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodStruct[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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.
func (*ZodStruct[T, R]) MustParse ¶
func (z *ZodStruct[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse panics on validation failure.
func (*ZodStruct[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodStruct[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse panics on validation failure with compile-time type safety.
func (*ZodStruct[T, R]) Nilable ¶
Nilable returns a schema that accepts nil values with pointer constraint.
func (*ZodStruct[T, R]) NonOptional ¶ added in v0.3.0
NonOptional enforces non-nil struct value.
func (*ZodStruct[T, R]) Optional ¶
Optional returns a schema that accepts nil values with pointer constraint.
func (*ZodStruct[T, R]) Overwrite ¶ added in v0.3.0
Overwrite transforms the parsed value while preserving the original type.
func (*ZodStruct[T, R]) Parse ¶
func (z *ZodStruct[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns a value of type R.
func (*ZodStruct[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodStruct[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodStruct[T, R]) PrefaultFunc ¶
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodStruct[T, R]) Shape ¶
func (z *ZodStruct[T, R]) Shape() core.StructSchema
Shape returns the struct field schemas.
func (*ZodStruct[T, R]) StrictParse ¶ added in v0.4.0
func (z *ZodStruct[T, R]) StrictParse(input T, ctx ...*core.ParseContext) (R, error)
StrictParse validates input with compile-time type safety.
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 applies a transformation to the parsed struct value.
func (*ZodStruct[T, R]) UnknownKeys ¶ added in v0.6.0
func (z *ZodStruct[T, R]) UnknownKeys() ObjectMode
UnknownKeys returns the unknown keys handling mode.
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(...)
func (*ZodStruct[T, R]) WithFieldNameTag ¶ added in v0.11.6
WithFieldNameTag returns a schema that resolves struct field names using the named struct tag (for example "yaml" or "toml") instead of the default "json".
type ZodStructDef ¶
type ZodStructDef struct {
core.ZodTypeDef
// Shape maps field names to field schemas.
Shape core.StructSchema
}
ZodStructDef defines the configuration for struct validation.
type ZodStructInternals ¶
type ZodStructInternals struct {
core.ZodTypeInternals
// Def points to the schema definition.
Def *ZodStructDef
// Shape maps field names to field schemas.
Shape core.StructSchema
// IsPartial reports whether omitted fields are allowed.
IsPartial bool
// PartialExceptions marks fields that remain required in partial mode.
PartialExceptions map[string]bool
// FieldNameTag is the struct tag used for field names (default "json").
FieldNameTag string
}
ZodStructInternals contains the internal state for struct schemas.
type ZodTime ¶ added in v0.3.0
type ZodTime[T TimeConstraint] struct { // contains filtered or unexported fields }
ZodTime is a type-safe time validation schema.
func CoercedTime ¶ added in v0.3.0
CoercedTime creates a time.Time schema with coercion enabled.
func CoercedTimePtr ¶ added in v0.3.0
CoercedTimePtr creates a *time.Time schema with coercion enabled.
func Time ¶ added in v0.3.0
Time creates a time.Time validation schema.
Time() // no parameters
Time("custom error") // string shorthand
Time(SchemaParams{...}) // full parameters
func TimeTyped ¶ added in v0.3.0
func TimeTyped[T TimeConstraint](params ...any) *ZodTime[T]
TimeTyped creates a time schema with explicit type parameterization.
func (*ZodTime[T]) And ¶ added in v0.6.0
func (z *ZodTime[T]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodTime[T]) Check ¶ added in v0.6.0
func (z *ZodTime[T]) Check(fn func(value T, payload *core.ParsePayload), params ...any) *ZodTime[T]
Check applies a custom validation function with full payload access (Zod v4 API).
func (*ZodTime[T]) CloneFrom ¶ added in v0.3.0
CloneFrom copies configuration from another schema of the same type.
func (*ZodTime[T]) Default ¶ added in v0.3.0
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodTime[T]) DefaultFunc ¶ added in v0.3.0
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodTime[T]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodTime[T]) ExactOptional ¶ added in v0.6.0
ExactOptional accepts absent keys but rejects explicit nil values. Unlike Optional, ExactOptional only accepts absent keys in object fields.
func (*ZodTime[T]) Internals ¶ added in v0.6.0
func (z *ZodTime[T]) Internals() *core.ZodTypeInternals
Internals returns the internal state of the schema.
func (*ZodTime[T]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodTime[T]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 in the global registry.
func (*ZodTime[T]) MustParse ¶ added in v0.3.0
func (z *ZodTime[T]) MustParse(input any, ctx ...*core.ParseContext) T
MustParse validates input and panics on failure.
func (*ZodTime[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodTime[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse requires exact type T and panics on failure.
func (*ZodTime[T]) Nilable ¶ added in v0.3.0
Nilable returns a new schema that accepts nil values, with *time.Time constraint.
func (*ZodTime[T]) NonOptional ¶ added in v0.6.0
NonOptional removes the optional flag, returning a time.Time constraint.
func (*ZodTime[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable modifiers.
func (*ZodTime[T]) Optional ¶ added in v0.3.0
Optional returns a new schema that accepts nil, with *time.Time constraint.
func (*ZodTime[T]) Overwrite ¶ added in v0.3.0
Overwrite transforms the input value while preserving the original type.
func (*ZodTime[T]) Parse ¶ added in v0.3.0
func (z *ZodTime[T]) Parse(input any, ctx ...*core.ParseContext) (T, error)
Parse validates input and returns a value of type T.
func (*ZodTime[T]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns any type for runtime interface usage.
func (*ZodTime[T]) Prefault ¶ added in v0.3.0
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodTime[T]) PrefaultFunc ¶ added in v0.3.0
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodTime[T]) Refine ¶ added in v0.3.0
Refine applies a custom validation function matching the schema's output type T.
func (*ZodTime[T]) RefineAny ¶ added in v0.3.0
RefineAny applies a custom validation function that receives the raw value.
func (*ZodTime[T]) StrictParse ¶ added in v0.4.0
func (z *ZodTime[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse requires exact type T for compile-time type safety.
type ZodTimeDef ¶ added in v0.3.0
type ZodTimeDef struct {
core.ZodTypeDef
}
ZodTimeDef holds the configuration for a time schema.
type ZodTimeInternals ¶ added in v0.3.0
type ZodTimeInternals struct {
core.ZodTypeInternals
Def *ZodTimeDef
}
ZodTimeInternals holds time validator internal state.
type ZodTuple ¶ added in v0.5.4
ZodTuple represents a type-safe tuple validation schema. T is the base type ([]any), R is the constraint type ([]any or *[]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.
func (*ZodTuple[T, R]) Default ¶ added in v0.5.4
Default sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodTuple[T, R]) Describe ¶ added in v0.5.4
Describe registers a description in the global registry.
func (*ZodTuple[T, R]) ExactOptional ¶ added in v0.6.0
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodTuple[T, R]) Internals ¶ added in v0.6.0
func (z *ZodTuple[T, R]) Internals() *core.ZodTypeInternals
Internals exposes the internal state for framework usage.
func (*ZodTuple[T, R]) IsNilable ¶ added in v0.5.4
IsNilable reports whether this schema accepts nil values.
func (*ZodTuple[T, R]) IsOptional ¶ added in v0.5.4
IsOptional reports whether this schema accepts undefined or missing values.
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]) 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 provides compile-time type safety and panics on failure.
func (*ZodTuple[T, R]) NonEmpty ¶ added in v0.5.4
NonEmpty ensures the tuple has at least one element.
func (*ZodTuple[T, R]) Nullish ¶ added in v0.5.4
Nullish marks this tuple as nullish (both optional and nilable).
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 the input and returns a value matching the constraint type R.
func (*ZodTuple[T, R]) ParseAny ¶ added in v0.5.4
ParseAny validates the input and returns any type for runtime interface usage.
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 the exact type T.
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.
type ZodTupleInternals ¶ added in v0.5.4
type ZodTupleInternals struct {
core.ZodTypeInternals
Def *ZodTupleDef
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] }
ZodULID validates strings in ULID format.
func (*ZodULID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodULID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodULID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodULID[T]) Meta ¶ added in v0.10.5
func (z *ZodULID[T]) Meta(meta core.GlobalMeta) *ZodULID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodULID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodULID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodULID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodULID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodULID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodULID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodULID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodULID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodULID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodURL ¶ added in v0.3.0
type ZodURL[T StringConstraint] struct{ *ZodString[T] }
ZodURL validates strings in URL format.
func CoercedURL ¶ added in v0.3.0
CoercedURL creates a coerced URL schema that attempts string conversion.
func HTTPURL ¶ added in v0.6.0
HTTPURL creates a URL validation schema that only accepts http:// or https:// protocols.
func HTTPURLPtr ¶ added in v0.6.0
HTTPURLPtr creates a pointer URL validation schema that only accepts http:// or https:// protocols.
func HTTPURLTyped ¶ added in v0.6.0
func HTTPURLTyped[T StringConstraint](params ...any) *ZodURL[T]
HTTPURLTyped creates a URL validation schema with the given type constraint that only accepts http:// or https:// protocols.
func URL ¶ added in v0.3.0
URL creates a URL validation schema. Accepts optional URLOptions as first parameter for custom validation.
func URLPtr ¶ added in v0.3.0
URLPtr creates a pointer URL validation schema. Accepts optional URLOptions as first parameter for custom validation.
func URLTyped ¶ added in v0.3.0
func URLTyped[T StringConstraint](params ...any) *ZodURL[T]
URLTyped creates a URL validation schema with the given type constraint. Accepts optional URLOptions as first parameter for custom validation.
func (*ZodURL[T]) Default ¶ added in v0.3.0
Default sets a fallback value returned when input is nil.
func (*ZodURL[T]) DefaultFunc ¶ added in v0.3.0
DefaultFunc sets a fallback function called when input is nil.
func (*ZodURL[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodURL[T]) Meta ¶ added in v0.10.5
func (z *ZodURL[T]) Meta(meta core.GlobalMeta) *ZodURL[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodURL[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodURL[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodURL[T]) Nullish ¶ added in v0.3.0
Nullish returns a new schema combining optional and nilable.
func (*ZodURL[T]) Prefault ¶ added in v0.3.0
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodURL[T]) PrefaultFunc ¶ added in v0.3.0
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodURL[T]) RefineAny ¶ added in v0.3.0
RefineAny adds custom validation that receives the raw value as any.
func (*ZodURL[T]) StrictParse ¶ added in v0.4.0
func (z *ZodURL[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodUUID ¶ added in v0.3.0
type ZodUUID[T StringConstraint] struct{ *ZodString[T] }
ZodUUID validates strings in UUID format.
func UUID ¶ added in v0.7.0
UUID creates a UUID schema with optional version parameter: "v4", "v6", "v7".
func UUIDPtr ¶ added in v0.7.0
UUIDPtr creates a pointer UUID schema with optional version parameter.
func (*ZodUUID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodUUID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodUUID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodUUID[T]) Meta ¶ added in v0.10.5
func (z *ZodUUID[T]) Meta(meta core.GlobalMeta) *ZodUUID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodUUID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodUUID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodUUID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodUUID[T]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts nil values.
func (*ZodUUID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodUUID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodUUID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodUUID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodUUID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodUnion ¶
ZodUnion validates that input matches at least one member schema. T is the base type, R is the constraint type (T or *T for optional/nilable).
func UnionOfPtr ¶ added in v0.3.0
UnionOfPtr creates a union schema from variadic arguments with pointer constraint.
func UnionTyped ¶ added in v0.3.0
UnionTyped creates a 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 of this schema with another.
func (*ZodUnion[T, R]) Default ¶
Default sets a value to use when input is nil, bypassing validation.
func (*ZodUnion[T, R]) DefaultFunc ¶
DefaultFunc sets a function to produce the default value when input is nil.
func (*ZodUnion[T, R]) Describe ¶ added in v0.5.4
Describe sets a human-readable description for this schema.
func (*ZodUnion[T, R]) Internals ¶ added in v0.6.0
func (z *ZodUnion[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state for framework usage.
func (*ZodUnion[T, R]) IsNilable ¶ added in v0.3.0
IsNilable reports whether this schema accepts nil values.
func (*ZodUnion[T, R]) IsOptional ¶ added in v0.3.0
IsOptional reports whether 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 attaches metadata to this schema.
func (*ZodUnion[T, R]) MustParse ¶
func (z *ZodUnion[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse is like Parse but panics on validation failure.
func (*ZodUnion[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodUnion[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse is like StrictParse but panics on validation failure.
func (*ZodUnion[T, R]) NonOptional ¶ added in v0.3.0
NonOptional returns a new schema that enforces non-nil values.
func (*ZodUnion[T, R]) Nullish ¶ added in v0.3.0
Nullish returns a new schema that accepts both undefined and nil values.
func (*ZodUnion[T, R]) Optional ¶
Optional returns a new schema that accepts undefined/missing values.
func (*ZodUnion[T, R]) Parse ¶
func (z *ZodUnion[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input against all union member schemas, returning the first match.
func (*ZodUnion[T, R]) ParseAny ¶ added in v0.3.0
ParseAny validates input and returns an untyped result.
func (*ZodUnion[T, R]) Pipe ¶
Pipe chains this schema's output into another schema for further validation.
func (*ZodUnion[T, R]) Prefault ¶
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodUnion[T, R]) PrefaultFunc ¶
PrefaultFunc sets a function to produce the prefault value.
func (*ZodUnion[T, R]) Refine ¶
Refine adds a custom validation check with type-safe access to the parsed value.
func (*ZodUnion[T, R]) RefineAny ¶
RefineAny adds a custom validation check operating on the raw value.
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.
func (*ZodUnion[T, R]) Transform ¶
func (z *ZodUnion[T, R]) Transform( fn func(T, *core.RefinementContext) (any, error), ) *core.ZodTransform[R, any]
Transform creates a type-safe transformation pipeline.
type ZodUnionDef ¶
type ZodUnionDef struct {
core.ZodTypeDef
Options []core.ZodSchema
}
ZodUnionDef holds the configuration for union validation.
type ZodUnionInternals ¶
type ZodUnionInternals struct {
core.ZodTypeInternals
Def *ZodUnionDef
Options []core.ZodSchema
}
ZodUnionInternals holds the internal state for a union schema.
type ZodUnknown ¶
ZodUnknown validates unknown values with dual generic parameters. T is the base type, R is the constraint type (T or *T).
func Unknown ¶
func Unknown(params ...any) *ZodUnknown[any, any]
Unknown creates a schema that accepts unknown values.
func UnknownPtr ¶ added in v0.3.0
func UnknownPtr(params ...any) *ZodUnknown[any, *any]
UnknownPtr creates a schema that accepts unknown values with pointer constraint.
func UnknownTyped ¶ added in v0.3.0
func UnknownTyped[T any, R any](params ...any) *ZodUnknown[T, R]
UnknownTyped creates a typed unknown schema with generic constraints.
func (*ZodUnknown[T, R]) And ¶ added in v0.6.0
func (z *ZodUnknown[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection with another schema.
func (*ZodUnknown[T, R]) Check ¶
func (z *ZodUnknown[T, R]) Check(fn func(value R, payload *core.ParsePayload), params ...any) *ZodUnknown[T, R]
Check adds a custom validation function that can push multiple issues.
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 sets a fallback value returned when input is nil (short-circuits validation).
func (*ZodUnknown[T, R]) DefaultFunc ¶
func (z *ZodUnknown[T, R]) DefaultFunc(fn func() T) *ZodUnknown[T, R]
DefaultFunc sets a fallback function called when input is nil (short-circuits validation).
func (*ZodUnknown[T, R]) Describe ¶ added in v0.5.4
func (z *ZodUnknown[T, R]) Describe(desc string) *ZodUnknown[T, R]
Describe registers a description in the global registry.
func (*ZodUnknown[T, R]) ExactOptional ¶ added in v0.6.0
func (z *ZodUnknown[T, R]) ExactOptional() *ZodUnknown[T, R]
ExactOptional accepts absent keys but rejects explicit nil values.
func (*ZodUnknown[T, R]) Internals ¶ added in v0.6.0
func (z *ZodUnknown[T, R]) Internals() *core.ZodTypeInternals
Internals 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 reports whether this schema accepts nil values.
func (*ZodUnknown[T, R]) IsOptional ¶ added in v0.3.0
func (z *ZodUnknown[T, R]) IsOptional() bool
IsOptional reports whether 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 in the global registry.
func (*ZodUnknown[T, R]) MustParse ¶
func (z *ZodUnknown[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse panics on validation error.
func (*ZodUnknown[T, R]) MustStrictParse ¶ added in v0.4.0
func (z *ZodUnknown[T, R]) MustStrictParse(input R, ctx ...*core.ParseContext) R
MustStrictParse panics on validation error with compile-time type safety.
func (*ZodUnknown[T, R]) Nilable ¶
func (z *ZodUnknown[T, R]) Nilable() *ZodUnknown[T, *T]
Nilable returns a pointer-typed schema that accepts nil values.
func (*ZodUnknown[T, R]) NonOptional ¶ added in v0.3.0
func (z *ZodUnknown[T, R]) NonOptional() *ZodUnknown[T, T]
NonOptional removes the optional flag and forces return type to T.
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 returns a pointer-typed schema that accepts missing values.
func (*ZodUnknown[T, R]) Or ¶ added in v0.6.0
func (z *ZodUnknown[T, R]) Or(other any) *ZodUnion[any, any]
Or creates a union with another schema.
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.
func (*ZodUnknown[T, R]) Parse ¶
func (z *ZodUnknown[T, R]) Parse(input any, ctx ...*core.ParseContext) (R, error)
Parse validates input and returns a value matching the generic type R.
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 input and returns an untyped result.
func (*ZodUnknown[T, R]) Prefault ¶
func (z *ZodUnknown[T, R]) Prefault(v T) *ZodUnknown[T, R]
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodUnknown[T, R]) PrefaultFunc ¶
func (z *ZodUnknown[T, R]) PrefaultFunc(fn func() T) *ZodUnknown[T, R]
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodUnknown[T, R]) Refine ¶
func (z *ZodUnknown[T, R]) Refine(fn func(R) bool, params ...any) *ZodUnknown[T, R]
Refine applies a custom validation function matching the schema's output type R.
func (*ZodUnknown[T, R]) RefineAny ¶
func (z *ZodUnknown[T, R]) RefineAny(fn func(any) bool, params ...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 type-safe parsing with compile-time guarantees.
func (*ZodUnknown[T, R]) Transform ¶
func (z *ZodUnknown[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform applies a transformation function.
func (*ZodUnknown[T, R]) With ¶ added in v0.6.0
func (z *ZodUnknown[T, R]) With(fn func(value R, payload *core.ParsePayload), params ...any) *ZodUnknown[T, R]
With is an alias for Check for Zod v4 API compatibility.
type ZodUnknownDef ¶
type ZodUnknownDef struct {
core.ZodTypeDef
}
ZodUnknownDef holds the configuration for unknown value validation.
type ZodUnknownInternals ¶
type ZodUnknownInternals struct {
core.ZodTypeInternals
Def *ZodUnknownDef
}
ZodUnknownInternals contains the internal state of an unknown validator.
type ZodXID ¶ added in v0.3.0
type ZodXID[T StringConstraint] struct{ *ZodString[T] }
ZodXID validates strings in XID format.
func (*ZodXID[T]) Default ¶ added in v0.10.5
Default sets a fallback value returned when input is nil.
func (*ZodXID[T]) DefaultFunc ¶ added in v0.10.5
DefaultFunc sets a fallback function called when input is nil.
func (*ZodXID[T]) Describe ¶ added in v0.10.5
Describe attaches a description to this schema via the global registry.
func (*ZodXID[T]) Meta ¶ added in v0.10.5
func (z *ZodXID[T]) Meta(meta core.GlobalMeta) *ZodXID[T]
Meta attaches metadata to this schema via the global registry.
func (*ZodXID[T]) MustStrictParse ¶ added in v0.4.0
func (z *ZodXID[T]) MustStrictParse(input T, ctx ...*core.ParseContext) T
MustStrictParse validates input with compile-time type safety and panics on error.
func (*ZodXID[T]) Nullish ¶ added in v0.6.0
Nullish returns a new schema combining optional and nilable.
func (*ZodXID[T]) Prefault ¶ added in v0.10.5
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodXID[T]) PrefaultFunc ¶ added in v0.10.5
PrefaultFunc sets a fallback function that goes through the full validation pipeline.
func (*ZodXID[T]) RefineAny ¶ added in v0.10.5
RefineAny adds custom validation that receives the raw value as any.
func (*ZodXID[T]) StrictParse ¶ added in v0.4.0
func (z *ZodXID[T]) StrictParse(input T, ctx ...*core.ParseContext) (T, error)
StrictParse validates input with compile-time type safety.
type ZodXor ¶ added in v0.5.4
ZodXor validates that input matches exactly one member schema. T is the base type, R is the constraint type (T or *T for optional/nilable).
func Xor ¶ added in v0.5.4
Xor creates an 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 XorOfPtr ¶ added in v0.5.4
XorOfPtr creates an exclusive union schema from variadic arguments with pointer constraint.
func XorPtr ¶ added in v0.5.4
XorPtr creates an exclusive union schema with pointer constraint type.
func XorTyped ¶ added in v0.5.4
XorTyped creates a typed exclusive union schema with generic constraints.
func (*ZodXor[T, R]) And ¶ added in v0.6.0
func (z *ZodXor[T, R]) And(other any) *ZodIntersection[any, any]
And creates an intersection of this schema with another.
func (*ZodXor[T, R]) CloneFrom ¶ added in v0.6.0
CloneFrom copies configuration from another schema.
func (*ZodXor[T, R]) Default ¶ added in v0.6.0
Default sets a value to use when input is nil, bypassing validation.
func (*ZodXor[T, R]) DefaultFunc ¶ added in v0.6.0
DefaultFunc sets a function to produce the default value when input is nil.
func (*ZodXor[T, R]) Describe ¶ added in v0.5.4
Describe sets a human-readable description for this schema.
func (*ZodXor[T, R]) Internals ¶ added in v0.6.0
func (z *ZodXor[T, R]) Internals() *core.ZodTypeInternals
Internals returns the internal state for framework usage.
func (*ZodXor[T, R]) IsNilable ¶ added in v0.5.4
IsNilable reports whether this schema accepts nil values.
func (*ZodXor[T, R]) IsOptional ¶ added in v0.5.4
IsOptional reports whether 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 attaches metadata to this schema.
func (*ZodXor[T, R]) MustParse ¶ added in v0.5.4
func (z *ZodXor[T, R]) MustParse(input any, ctx ...*core.ParseContext) R
MustParse is like Parse but panics on validation failure.
func (*ZodXor[T, R]) MustStrictParse ¶ added in v0.5.4
func (z *ZodXor[T, R]) MustStrictParse(input T, ctx ...*core.ParseContext) R
MustStrictParse is like StrictParse but panics on validation failure.
func (*ZodXor[T, R]) Nilable ¶ added in v0.6.0
Nilable returns a new schema that accepts nil values.
func (*ZodXor[T, R]) NonOptional ¶ added in v0.6.0
NonOptional returns a new schema that enforces non-nil values.
func (*ZodXor[T, R]) Nullish ¶ added in v0.6.0
Nullish returns a new schema that accepts both undefined and nil values.
func (*ZodXor[T, R]) Optional ¶ added in v0.6.0
Optional returns a new schema that accepts undefined/missing values.
func (*ZodXor[T, R]) Options ¶ added in v0.5.4
Options returns a copy of all exclusive union member schemas.
func (*ZodXor[T, R]) Or ¶ added in v0.6.0
Or creates a union of this schema with another, enabling chaining.
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
ParseAny validates input and returns an untyped result for runtime scenarios.
func (*ZodXor[T, R]) Pipe ¶ added in v0.6.0
Pipe chains this schema's output into another schema for further validation.
func (*ZodXor[T, R]) Prefault ¶ added in v0.6.0
Prefault sets a fallback value that goes through the full validation pipeline.
func (*ZodXor[T, R]) PrefaultFunc ¶ added in v0.6.0
PrefaultFunc sets a function to produce the prefault value.
func (*ZodXor[T, R]) Refine ¶ added in v0.6.0
Refine adds a custom validation check with type-safe access to the parsed value.
func (*ZodXor[T, R]) RefineAny ¶ added in v0.6.0
RefineAny adds a custom validation check operating on the raw value.
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. The input must exactly match the schema's base type T.
func (*ZodXor[T, R]) Transform ¶ added in v0.6.0
func (z *ZodXor[T, R]) Transform(fn func(T, *core.RefinementContext) (any, error)) *core.ZodTransform[R, any]
Transform creates a type-safe transformation pipeline.
type ZodXorDef ¶ added in v0.5.4
type ZodXorDef struct {
core.ZodTypeDef
Options []core.ZodSchema
}
ZodXorDef defines the schema definition for exclusive union validation.
type ZodXorInternals ¶ added in v0.5.4
type ZodXorInternals struct {
core.ZodTypeInternals
Def *ZodXorDef
Options []core.ZodSchema
}
ZodXorInternals contains the internal state for exclusive union schema.
Source Files
¶
- any.go
- array.go
- bigint.go
- bool.go
- clonefrom.go
- complex.go
- discriminated_union.go
- doc.go
- email.go
- enum.go
- file.go
- float.go
- function.go
- ids.go
- integer.go
- intersection.go
- iso.go
- lazy.go
- literal.go
- map.go
- network.go
- never.go
- nil.go
- object.go
- record.go
- set.go
- slice.go
- string.go
- string_format_fluent.go
- stringbool.go
- struct.go
- text.go
- time.go
- tuple.go
- union.go
- unknown.go
- xor.go