(input)
| 31192 | return this._cached = { shape, keys }; |
| 31193 | } |
| 31194 | _parse(input) { |
| 31195 | const parsedType = this._getType(input); |
| 31196 | if (parsedType !== util_1.ZodParsedType.object) { |
| 31197 | const ctx2 = this._getOrReturnCtx(input); |
| 31198 | (0, parseUtil_1.addIssueToContext)(ctx2, { |
| 31199 | code: ZodError_1.ZodIssueCode.invalid_type, |
| 31200 | expected: util_1.ZodParsedType.object, |
| 31201 | received: ctx2.parsedType |
| 31202 | }); |
| 31203 | return parseUtil_1.INVALID; |
| 31204 | } |
| 31205 | const { status, ctx } = this._processInputParams(input); |
| 31206 | const { shape, keys: shapeKeys } = this._getCached(); |
| 31207 | const extraKeys = []; |
| 31208 | if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { |
| 31209 | for (const key in ctx.data) { |
| 31210 | if (!shapeKeys.includes(key)) { |
| 31211 | extraKeys.push(key); |
| 31212 | } |
| 31213 | } |
| 31214 | } |
| 31215 | const pairs = []; |
| 31216 | for (const key of shapeKeys) { |
| 31217 | const keyValidator = shape[key]; |
| 31218 | const value = ctx.data[key]; |
| 31219 | pairs.push({ |
| 31220 | key: { status: "valid", value: key }, |
| 31221 | value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), |
| 31222 | alwaysSet: key in ctx.data |
| 31223 | }); |
| 31224 | } |
| 31225 | if (this._def.catchall instanceof ZodNever) { |
| 31226 | const unknownKeys = this._def.unknownKeys; |
| 31227 | if (unknownKeys === "passthrough") { |
| 31228 | for (const key of extraKeys) { |
| 31229 | pairs.push({ |
| 31230 | key: { status: "valid", value: key }, |
| 31231 | value: { status: "valid", value: ctx.data[key] } |
| 31232 | }); |
| 31233 | } |
| 31234 | } else if (unknownKeys === "strict") { |
| 31235 | if (extraKeys.length > 0) { |
| 31236 | (0, parseUtil_1.addIssueToContext)(ctx, { |
| 31237 | code: ZodError_1.ZodIssueCode.unrecognized_keys, |
| 31238 | keys: extraKeys |
| 31239 | }); |
| 31240 | status.dirty(); |
| 31241 | } |
| 31242 | } else if (unknownKeys === "strip") { |
| 31243 | } else { |
| 31244 | throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); |
| 31245 | } |
| 31246 | } else { |
| 31247 | const catchall = this._def.catchall; |
| 31248 | for (const key of extraKeys) { |
| 31249 | const value = ctx.data[key]; |
| 31250 | pairs.push({ |
| 31251 | key: { status: "valid", value: key }, |
nothing calls this directly
no test coverage detected