| 4483 | export type ZodOptionalType<T extends ZodTypeAny> = ZodOptional<T>; |
| 4484 | |
| 4485 | export class ZodOptional<T extends ZodTypeAny> extends ZodType< |
| 4486 | T["_output"] | undefined, |
| 4487 | ZodOptionalDef<T>, |
| 4488 | T["_input"] | undefined |
| 4489 | > { |
| 4490 | _parse(input: ParseInput): ParseReturnType<this["_output"]> { |
| 4491 | const parsedType = this._getType(input); |
| 4492 | if (parsedType === ZodParsedType.undefined) { |
| 4493 | return OK(undefined); |
| 4494 | } |
| 4495 | return this._def.innerType._parse(input); |
| 4496 | } |
| 4497 | |
| 4498 | unwrap() { |
| 4499 | return this._def.innerType; |
| 4500 | } |
| 4501 | |
| 4502 | static create = <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams): ZodOptional<Inner> => { |
| 4503 | return new ZodOptional({ |
| 4504 | innerType: type, |
| 4505 | typeName: ZodFirstPartyTypeKind.ZodOptional, |
| 4506 | ...processCreateParams(params), |
| 4507 | }) as any; |
| 4508 | }; |
| 4509 | } |
| 4510 | |
| 4511 | /////////////////////////////////////////// |
| 4512 | /////////////////////////////////////////// |
nothing calls this directly
no test coverage detected