zod
Version:
Typescript-first schema declaration and validation library with static type inference
23 lines (19 loc) • 633 B
text/typescript
import * as z from './base';
import { ZodUndefined } from './undefined';
import { ZodNull } from './null';
import { ZodUnion } from './union';
export interface ZodNumberDef extends z.ZodTypeDef {
t: z.ZodTypes.number;
}
export class ZodNumber extends z.ZodType<number, ZodNumberDef> {
optional: () => ZodUnion<[this, ZodUndefined]> = () =>
ZodUnion.create([this, ZodUndefined.create()]);
nullable: () => ZodUnion<[this, ZodNull]> = () =>
ZodUnion.create([this, ZodNull.create()]);
toJSON = () => this._def;
static create = (): ZodNumber => {
return new ZodNumber({
t: z.ZodTypes.number,
});
};
}