mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
27 lines
735 B
TypeScript
27 lines
735 B
TypeScript
// Loaded from https://raw.githubusercontent.com/colinhacks/zod/654680afc2ede388e71e09104eac5a0088fe3207/deno/lib/types/nativeEnum.ts
|
|
|
|
|
|
import { ZodTypes } from "../ZodTypes.ts";
|
|
import { ZodType, ZodTypeDef } from "./base.ts";
|
|
|
|
export interface ZodNativeEnumDef<T extends EnumLike = EnumLike>
|
|
extends ZodTypeDef {
|
|
t: ZodTypes.nativeEnum;
|
|
values: T;
|
|
}
|
|
|
|
type EnumLike = { [k: string]: string | number; [nu: number]: string };
|
|
|
|
export class ZodNativeEnum<T extends EnumLike> extends ZodType<
|
|
T[keyof T],
|
|
ZodNativeEnumDef<T>
|
|
> {
|
|
toJSON = () => this._def;
|
|
static create = <T extends EnumLike>(values: T): ZodNativeEnum<T> => {
|
|
return new ZodNativeEnum({
|
|
t: ZodTypes.nativeEnum,
|
|
values: values,
|
|
});
|
|
};
|
|
}
|