swc/bundler/tests/.cache/untrusted/871434ddb32f78e77a9edeebe4dd1cec6c1fec94.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

32 lines
1.0 KiB
TypeScript

// Loaded from https://raw.githubusercontent.com/colinhacks/zod/654680afc2ede388e71e09104eac5a0088fe3207/deno/lib/types/literal.ts
// import { ZodUndefined } from './undefined';
// import { ZodNull } from './null';
// import { ZodUnion } from './union';
import { Primitive } from "../helpers/primitive.ts";
import { ZodTypes } from "../ZodTypes.ts";
import { ZodType, ZodTypeDef } from "./base.ts";
type LiteralValue = Primitive;
export interface ZodLiteralDef<T extends any = any> extends ZodTypeDef {
t: ZodTypes.literal;
value: T;
}
export class ZodLiteral<T extends any> extends ZodType<T, ZodLiteralDef<T>> {
// opt optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]);
// null nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]);
toJSON = () => this._def;
static create = <T extends LiteralValue>(value: T): ZodLiteral<T> => {
return new ZodLiteral({
t: ZodTypes.literal,
value: value,
});
};
}