title: Core.z. Zod Optional
A2A Node SDK - v0.1.0 / Modules / Core / z / ZodOptional
Class: ZodOptional<T>
Type parameters
| Name | Type |
|---|---|
T | extends ZodTypeAny |
Hierarchy
-
ZodType<T["_output"] |undefined,ZodOptionalDef<T>,T["_input"] |undefined>↳
ZodOptional
Table of contents
Constructors
Properties
Accessors
Methods
- _getOrReturnCtx
- _getType
- _parse
- _parseAsync
- _parseSync
- _processInputParams
- _refinement
- and
- array
- brand
- catch
- default
- describe
- isNullable
- isOptional
- nullable
- nullish
- optional
- or
- parse
- parseAsync
- pipe
- promise
- readonly
- refine
- refinement
- safeParse
- safeParseAsync
- superRefine
- transform
- unwrap
- ~validate
Constructors
constructor
• new ZodOptional<T>(def): ZodOptional<T>
Type parameters
| Name | Type |
|---|---|
T | extends ZodTypeAny |
Parameters
| Name | Type |
|---|---|
def | ZodOptionalDef<T> |
Returns
ZodOptional<T>
Inherited from
Properties
_def
• Readonly _def: ZodOptionalDef<T>
Inherited from
_input
• Readonly _input: undefined | T["_input"]
Inherited from
_output
• Readonly _output: undefined | T["_output"]
Inherited from
_type
• Readonly _type: undefined | T["_output"]
Inherited from
create
▪ Static create: <Inner>(type: Inner, params?: RawCreateParams) => ZodOptional<Inner>
Type declaration
▸ <Inner>(type, params?): ZodOptional<Inner>
Type parameters
| Name | Type |
|---|---|
Inner | extends ZodTypeAny |
Parameters
| Name | Type |
|---|---|
type | Inner |
params? | RawCreateParams |
Returns
ZodOptional<Inner>
spa
• spa: (data: unknown, params?: InexactPartial<ParseParams>) => Promise<SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>>
Alias of safeParseAsync
Type declaration
▸ (data, params?): Promise<SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>>
Parameters
| Name | Type |
|---|---|
data | unknown |
params? | InexactPartial<ParseParams> |
Returns
Promise<SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>>
Inherited from
~standard
• ~standard: Props<undefined | T["_input"], undefined | T["_output"]>
Inherited from
Accessors
description
• get description(): undefined | string
Returns
undefined | string
Inherited from
ZodType.description
Methods
_getOrReturnCtx
▸ _getOrReturnCtx(input, ctx?): ParseContext
Parameters
| Name | Type |
|---|---|
input | ParseInput |
ctx? | ParseContext |
Returns
Inherited from
_getType
▸ _getType(input): string
Parameters
| Name | Type |
|---|---|
input | ParseInput |
Returns
string
Inherited from
_parse
▸ _parse(input): ParseReturnType<undefined | T["_output"]>
Parameters
| Name | Type |
|---|---|
input | ParseInput |
Returns
ParseReturnType<undefined | T["_output"]>
Overrides
_parseAsync
▸ _parseAsync(input): AsyncParseReturnType<undefined | T["_output"]>
Parameters
| Name | Type |
|---|---|
input | ParseInput |
Returns
AsyncParseReturnType<undefined | T["_output"]>
Inherited from
_parseSync
▸ _parseSync(input): SyncParseReturnType<undefined | T["_output"]>
Parameters
| Name | Type |
|---|---|
input | ParseInput |
Returns
SyncParseReturnType<undefined | T["_output"]>
Inherited from
_processInputParams
▸ _processInputParams(input): Object
Parameters
| Name | Type |
|---|---|
input | ParseInput |
Returns
Object
| Name | Type |
|---|---|
ctx | ParseContext |
status | ParseStatus |
Inherited from
_refinement
▸ _refinement(refinement): ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Parameters
| Name | Type |
|---|---|
refinement | (arg: undefined | T["_output"], ctx: RefinementCtx) => any |
Returns
ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Inherited from
and
▸ and<T>(incoming): ZodIntersection<ZodOptional<T>, T>
Type parameters
| Name | Type |
|---|---|
T | extends ZodTypeAny |
Parameters
| Name | Type |
|---|---|
incoming | T |
Returns
ZodIntersection<ZodOptional<T>, T>
Inherited from
array
▸ array(): ZodArray<ZodOptional<T>, "many">
Returns
ZodArray<ZodOptional<T>, "many">
Inherited from
brand
▸ brand<B>(brand?): ZodBranded<ZodOptional<T>, B>
Type parameters
| Name | Type |
|---|---|
B | extends string | number | symbol |
Parameters
| Name | Type |
|---|---|
brand? | B |
Returns
ZodBranded<ZodOptional<T>, B>
Inherited from
catch
▸ catch(def): ZodCatch<ZodOptional<T>>
Parameters
| Name | Type |
|---|---|
def | undefined | T["_output"] |
Returns
ZodCatch<ZodOptional<T>>
Inherited from
▸ catch(def): ZodCatch<ZodOptional<T>>
Parameters
| Name | Type |
|---|---|
def | (ctx: { error: ZodError<any> ; input: undefined | T["_input"] }) => undefined | T["_output"] |
Returns
ZodCatch<ZodOptional<T>>
Inherited from
default
▸ default(def): ZodDefault<ZodOptional<T>>
Parameters
| Name | Type |
|---|---|
def | noUndefined<T["_input"]> |
Returns
Inherited from
▸ default(def): ZodDefault<ZodOptional<T>>
Parameters
| Name | Type |
|---|---|
def | () => noUndefined<T["_input"]> |
Returns
Inherited from
describe
▸ describe(description): this
Parameters
| Name | Type |
|---|---|
description | string |
Returns
this
Inherited from
isNullable
▸ isNullable(): boolean
Returns
boolean
Inherited from
isOptional
▸ isOptional(): boolean
Returns
boolean
Inherited from
nullable
▸ nullable(): ZodNullable<ZodOptional<T>>
Returns
Inherited from
nullish
▸ nullish(): ZodOptional<ZodNullable<ZodOptional<T>>>
Returns
ZodOptional<ZodNullable<ZodOptional<T>>>
Inherited from
optional
▸ optional(): ZodOptional<ZodOptional<T>>
Returns
Inherited from
or
▸ or<T>(option): ZodUnion<[ZodOptional<T>, T]>
Type parameters
| Name | Type |
|---|---|
T | extends ZodTypeAny |
Parameters
| Name | Type |
|---|---|
option | T |
Returns
ZodUnion<[ZodOptional<T>, T]>
Inherited from
parse
▸ parse(data, params?): undefined | T["_output"]
Parameters
| Name | Type |
|---|---|
data | unknown |
params? | InexactPartial<ParseParams> |
Returns
undefined | T["_output"]
Inherited from
parseAsync
▸ parseAsync(data, params?): Promise<undefined | T["_output"]>
Parameters
| Name | Type |
|---|---|
data | unknown |
params? | InexactPartial<ParseParams> |
Returns
Promise<undefined | T["_output"]>
Inherited from
pipe
▸ pipe<T>(target): ZodPipeline<ZodOptional<T>, T>
Type parameters
| Name | Type |
|---|---|
T | extends ZodTypeAny |
Parameters
| Name | Type |
|---|---|
target | T |
Returns
ZodPipeline<ZodOptional<T>, T>
Inherited from
promise
▸ promise(): ZodPromise<ZodOptional<T>>
Returns
Inherited from
readonly
▸ readonly(): ZodReadonly<ZodOptional<T>>
Returns
Inherited from
refine
▸ refine<RefinedOutput>(check, message?): ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Type parameters
| Name | Type |
|---|---|
RefinedOutput | extends any |
Parameters
| Name | Type |
|---|---|
check | (arg: undefined | T["_output"]) => arg is RefinedOutput |
message? | string | Partial<Omit<ZodCustomIssue, "code">> | (arg: undefined | T["_output"]) => Partial<Omit<ZodCustomIssue, "code">> |
Returns
ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Inherited from
▸ refine(check, message?): ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Parameters
| Name | Type |
|---|---|
check | (arg: undefined | T["_output"]) => unknown |
message? | string | Partial<Omit<ZodCustomIssue, "code">> | (arg: undefined | T["_output"]) => Partial<Omit<ZodCustomIssue, "code">> |
Returns
ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Inherited from
refinement
▸ refinement<RefinedOutput>(check, refinementData): ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Type parameters
| Name | Type |
|---|---|
RefinedOutput | extends any |
Parameters
| Name | Type |
|---|---|
check | (arg: undefined | T["_output"]) => arg is RefinedOutput |
refinementData | IssueData | (arg: undefined | T["_output"], ctx: RefinementCtx) => IssueData |
Returns
ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Inherited from
▸ refinement(check, refinementData): ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Parameters
| Name | Type |
|---|---|
check | (arg: undefined | T["_output"]) => boolean |
refinementData | IssueData | (arg: undefined | T["_output"], ctx: RefinementCtx) => IssueData |
Returns
ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Inherited from
safeParse
▸ safeParse(data, params?): SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>
Parameters
| Name | Type |
|---|---|
data | unknown |
params? | InexactPartial<ParseParams> |
Returns
SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>
Inherited from
safeParseAsync
▸ safeParseAsync(data, params?): Promise<SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>>
Parameters
| Name | Type |
|---|---|
data | unknown |
params? | InexactPartial<ParseParams> |
Returns
Promise<SafeParseReturnType<undefined | T["_input"], undefined | T["_output"]>>
Inherited from
superRefine
▸ superRefine<RefinedOutput>(refinement): ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Type parameters
| Name | Type |
|---|---|
RefinedOutput | extends any |
Parameters
| Name | Type |
|---|---|
refinement | (arg: undefined | T["_output"], ctx: RefinementCtx) => arg is RefinedOutput |
Returns
ZodEffects<ZodOptional<T>, RefinedOutput, undefined | T["_input"]>
Inherited from
▸ superRefine(refinement): ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Parameters
| Name | Type |
|---|---|
refinement | (arg: undefined | T["_output"], ctx: RefinementCtx) => void |
Returns
ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Inherited from
▸ superRefine(refinement): ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Parameters
| Name | Type |
|---|---|
refinement | (arg: undefined | T["_output"], ctx: RefinementCtx) => Promise<void> |
Returns
ZodEffects<ZodOptional<T>, undefined | T["_output"], undefined | T["_input"]>
Inherited from
transform
▸ transform<NewOut>(transform): ZodEffects<ZodOptional<T>, NewOut, undefined | T["_input"]>
Type parameters
| Name |
|---|
NewOut |
Parameters
| Name | Type |
|---|---|
transform | (arg: undefined | T["_output"], ctx: RefinementCtx) => NewOut | Promise<NewOut> |
Returns
ZodEffects<ZodOptional<T>, NewOut, undefined | T["_input"]>
Inherited from
unwrap
▸ unwrap(): T
Returns
T
~validate
▸ ~validate(data): Result<undefined | T["_output"]> | Promise<Result<undefined | T["_output"]>>
Parameters
| Name | Type |
|---|---|
data | unknown |
Returns
Result<undefined | T["_output"]> | Promise<Result<undefined | T["_output"]>>