MCPcopy
hub / github.com/colinhacks/zod / ZodNull

Class ZodNull

packages/zod/src/v3/types.ts:2079–2099  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2077}
2078
2079export class ZodNull extends ZodType<null, ZodNullDef, null> {
2080 _parse(input: ParseInput): ParseReturnType<this["_output"]> {
2081 const parsedType = this._getType(input);
2082 if (parsedType !== ZodParsedType.null) {
2083 const ctx = this._getOrReturnCtx(input);
2084 addIssueToContext(ctx, {
2085 code: ZodIssueCode.invalid_type,
2086 expected: ZodParsedType.null,
2087 received: ctx.parsedType,
2088 });
2089 return INVALID;
2090 }
2091 return OK(input.data);
2092 }
2093 static create = (params?: RawCreateParams): ZodNull => {
2094 return new ZodNull({
2095 typeName: ZodFirstPartyTypeKind.ZodNull,
2096 ...processCreateParams(params),
2097 });
2098 };
2099}
2100
2101//////////////////////////////////////
2102//////////////////////////////////////

Callers

nothing calls this directly

Calls 1

processCreateParamsFunction · 0.85

Tested by

no test coverage detected