zod
Advanced tools
Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "zod", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"description": "Typescript-first schema declaration and validation library with static type inference", | ||
@@ -5,0 +5,0 @@ "main": "index.ts", |
31
tests.ts
@@ -1,21 +0,14 @@ | ||
import * as z from '.'; | ||
// import * as z from '.'; | ||
interface Category { | ||
name: string; | ||
categories: Array<Category>; | ||
} | ||
// interface Category { | ||
// name: string; | ||
// categories: Array<Category>; | ||
// } | ||
const Cat: z.ZodType<Category> = z.lazy(() => { | ||
// console.log(Cat); | ||
return z.object({ | ||
name: z.string(), | ||
categories: z.array(Cat), | ||
}); | ||
}); | ||
// const inp = z.string(); | ||
// const outp = z.number(); | ||
// const fun = z.function(z.tuple([inp]), outp); | ||
// fun.validate((s)=>{ | ||
// return 4 | ||
// }) | ||
// const Cat: z.ZodType<Category> = z.lazy(() => { | ||
// // console.log(Cat); | ||
// return z.object({ | ||
// name: z.string(), | ||
// categories: z.array(Cat), | ||
// }); | ||
// }); |
@@ -7,3 +7,3 @@ import * as z from './base'; | ||
export interface ZodTupleDef< | ||
T extends [z.ZodAny, ...z.ZodAny[]] = [z.ZodAny, ...z.ZodAny[]] | ||
T extends [z.ZodAny, ...z.ZodAny[]] | [] = [z.ZodAny, ...z.ZodAny[]] | ||
> extends z.ZodTypeDef { | ||
@@ -15,7 +15,7 @@ t: z.ZodTypes.tuple; | ||
export class ZodTuple< | ||
T extends [z.ZodAny, ...z.ZodAny[]] = [z.ZodAny, ...z.ZodAny[]] | ||
T extends [z.ZodAny, ...z.ZodAny[]] | [] = [z.ZodAny, ...z.ZodAny[]] | ||
> extends z.ZodType<z.TypeOfTuple<T>, ZodTupleDef<T>> { | ||
toJSON = () => ({ | ||
t: this._def.t, | ||
items: this._def.items.map(item => item.toJSON()), | ||
items: (this._def.items as any[]).map(item => item.toJSON()), | ||
}); | ||
@@ -28,3 +28,3 @@ | ||
static create = <T extends [z.ZodAny, ...z.ZodAny[]]>( | ||
static create = <T extends [z.ZodAny, ...z.ZodAny[]] | []>( | ||
schemas: T | ||
@@ -31,0 +31,0 @@ ): ZodTuple<T> => { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
44056
981
1