| 4523 | export type ZodNullableType<T extends ZodTypeAny> = ZodNullable<T>; |
| 4524 | |
| 4525 | export class ZodNullable<T extends ZodTypeAny> extends ZodType< |
| 4526 | T["_output"] | null, |
| 4527 | ZodNullableDef<T>, |
| 4528 | T["_input"] | null |
| 4529 | > { |
| 4530 | _parse(input: ParseInput): ParseReturnType<this["_output"]> { |
| 4531 | const parsedType = this._getType(input); |
| 4532 | if (parsedType === ZodParsedType.null) { |
| 4533 | return OK(null); |
| 4534 | } |
| 4535 | return this._def.innerType._parse(input); |
| 4536 | } |
| 4537 | |
| 4538 | unwrap() { |
| 4539 | return this._def.innerType; |
| 4540 | } |
| 4541 | |
| 4542 | static create = <Inner extends ZodTypeAny>(type: Inner, params?: RawCreateParams): ZodNullable<Inner> => { |
| 4543 | return new ZodNullable({ |
| 4544 | innerType: type, |
| 4545 | typeName: ZodFirstPartyTypeKind.ZodNullable, |
| 4546 | ...processCreateParams(params), |
| 4547 | }) as any; |
| 4548 | }; |
| 4549 | } |
| 4550 | |
| 4551 | //////////////////////////////////////////// |
| 4552 | //////////////////////////////////////////// |
nothing calls this directly
no test coverage detected