mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
// Loaded from https://raw.githubusercontent.com/colinhacks/zod/654680afc2ede388e71e09104eac5a0088fe3207/deno/lib/types/record.ts
|
|
|
|
|
|
import { ZodTypes } from "../ZodTypes.ts";
|
|
import { ZodType, ZodTypeDef, ZodTypeAny } from "./base.ts";
|
|
|
|
// import { ZodUndefined } from './undefined';
|
|
// import { ZodNull } from './null';
|
|
// import { ZodUnion } from './union';
|
|
|
|
export interface ZodRecordDef<Value extends ZodTypeAny = ZodTypeAny>
|
|
extends ZodTypeDef {
|
|
t: ZodTypes.record;
|
|
valueType: Value;
|
|
}
|
|
|
|
export class ZodRecord<Value extends ZodTypeAny = ZodTypeAny> extends ZodType<
|
|
Record<string, Value["_output"]>, // { [k in keyof T]: T[k]['_type'] },
|
|
ZodRecordDef<Value>,
|
|
Record<string, Value["_input"]>
|
|
> {
|
|
readonly _value!: Value;
|
|
|
|
toJSON = () => ({
|
|
t: this._def.t,
|
|
valueType: this._def.valueType.toJSON(),
|
|
});
|
|
|
|
// opt optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]);
|
|
|
|
// null nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]);
|
|
|
|
static create = <Value extends ZodTypeAny = ZodTypeAny>(
|
|
valueType: Value
|
|
): ZodRecord<Value> => {
|
|
return new ZodRecord({
|
|
t: ZodTypes.record,
|
|
valueType,
|
|
});
|
|
};
|
|
}
|