Adds getters to Map for key + value (#2356)

This commit is contained in:
Brent Barbata 2023-05-21 18:16:16 -07:00 committed by GitHub
parent a3c525658b
commit 4f75cbc682
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

BIN
bun.lockb Executable file

Binary file not shown.

View File

@ -3441,6 +3441,12 @@ export class ZodMap<
ZodMapDef<Key, Value>,
Map<Key["_input"], Value["_input"]>
> {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(input: ParseInput): ParseReturnType<this["_output"]> {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.map) {

View File

@ -3441,6 +3441,12 @@ export class ZodMap<
ZodMapDef<Key, Value>,
Map<Key["_input"], Value["_input"]>
> {
get keySchema() {
return this._def.keyType;
}
get valueSchema() {
return this._def.valueType;
}
_parse(input: ParseInput): ParseReturnType<this["_output"]> {
const { status, ctx } = this._processInputParams(input);
if (ctx.parsedType !== ZodParsedType.map) {