Test case
1 generated file · +7 −7test/inputs/schema/minmaxlength.schema
Mschema-typescript-zoddefault / TopLevel.ts+7 −7
| @@ -2,13 +2,13 @@ import * as z from "zod"; | ||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | export const TopLevelSchema = z.object({ |
| 5 | - "intersection": z.string().min(4).max(5), | |
| 6 | - "inUnion": z.union([z.number(), z.string().min(3).max(5)]), | |
| 7 | - "maxlength": z.string().max(5), | |
| 8 | - "minlength": z.string().min(3), | |
| 9 | - "minMaxIntersection": z.string().min(3).max(5), | |
| 10 | - "minmaxlength": z.string().min(3).max(5), | |
| 5 | + "intersection": z.string().refine(value => Array.from(value).length >= 4).refine(value => Array.from(value).length <= 5), | |
| 6 | + "inUnion": z.union([z.number(), z.string().refine(value => Array.from(value).length >= 3).refine(value => Array.from(value).length <= 5)]), | |
| 7 | + "maxlength": z.string().refine(value => Array.from(value).length <= 5), | |
| 8 | + "minlength": z.string().refine(value => Array.from(value).length >= 3), | |
| 9 | + "minMaxIntersection": z.string().refine(value => Array.from(value).length >= 3).refine(value => Array.from(value).length <= 5), | |
| 10 | + "minmaxlength": z.string().refine(value => Array.from(value).length >= 3).refine(value => Array.from(value).length <= 5), | |
| 11 | 11 | "minMaxUnion": z.string(), |
| 12 | - "union": z.string().min(3).max(6), | |
| 12 | + "union": z.string().refine(value => Array.from(value).length >= 3).refine(value => Array.from(value).length <= 6), | |
| 13 | 13 | }); |
| 14 | 14 | export type TopLevel = z.infer<typeof TopLevelSchema>; |
Test case
1 generated file · +2 −2test/inputs/schema/optional-const-ref.schema
Mschema-typescript-zoddefault / TopLevel.ts+2 −2
| @@ -10,10 +10,10 @@ export type Coordinate = z.infer<typeof CoordinateSchema>; | ||
| 10 | 10 | export const TopLevelSchema = z.object({ |
| 11 | 11 | "coordinates": z.array(CoordinateSchema).optional(), |
| 12 | 12 | "count": z.number().int().min(1).max(100).optional(), |
| 13 | - "label": z.string().min(2).max(16).optional(), | |
| 13 | + "label": z.string().refine(value => Array.from(value).length >= 2).refine(value => Array.from(value).length <= 16).optional(), | |
| 14 | 14 | "requiredCoordinates": z.array(CoordinateSchema), |
| 15 | 15 | "requiredCount": z.number().int().min(1).max(100), |
| 16 | - "requiredLabel": z.string().min(2).max(16), | |
| 16 | + "requiredLabel": z.string().refine(value => Array.from(value).length >= 2).refine(value => Array.from(value).length <= 16), | |
| 17 | 17 | "weight": z.number().min(0.5).max(99.5).optional(), |
| 18 | 18 | }); |
| 19 | 19 | export type TopLevel = z.infer<typeof TopLevelSchema>; |
Test case
1 generated file · +1 −1test/inputs/schema/optional-constraints.schema
Mschema-typescript-zoddefault / TopLevel.ts+1 −1
| @@ -5,7 +5,7 @@ export const TopLevelSchema = z.object({ | ||
| 5 | 5 | "optDouble": z.number().min(0.5).max(99.5).optional(), |
| 6 | 6 | "optInt": z.number().int().min(0).max(100).optional(), |
| 7 | 7 | "optPattern": z.string().regex(new RegExp("^[a-z]+$")).optional(), |
| 8 | - "optString": z.string().min(3).max(10).optional(), | |
| 8 | + "optString": z.string().refine(value => Array.from(value).length >= 3).refine(value => Array.from(value).length <= 10).optional(), | |
| 9 | 9 | "reqZeroMin": z.number().int().min(0).max(100), |
| 10 | 10 | }); |
| 11 | 11 | export type TopLevel = z.infer<typeof TopLevelSchema>; |
Test case
1 generated file · +2 −2test/inputs/schema/renaming-bug.schema
Mschema-typescript-zoddefault / TopLevel.ts+2 −2
| @@ -78,7 +78,7 @@ export type Geometry = z.infer<typeof GeometrySchema>; | ||
| 78 | 78 | |
| 79 | 79 | export const VehicleSchema = z.object({ |
| 80 | 80 | "brand": z.string().optional(), |
| 81 | - "id": z.string().min(1).optional(), | |
| 81 | + "id": z.string().refine(value => Array.from(value).length >= 1).optional(), | |
| 82 | 82 | "speed": SpeedSchema.optional(), |
| 83 | 83 | "subModule": z.boolean().optional(), |
| 84 | 84 | "type": VehicleTypeSchema.optional(), |
| @@ -94,7 +94,7 @@ export type Shape = z.infer<typeof ShapeSchema>; | ||
| 94 | 94 | |
| 95 | 95 | export const BerrySchema = z.object({ |
| 96 | 96 | "color": ColorSchema.optional(), |
| 97 | - "name": z.string().min(1).optional(), | |
| 97 | + "name": z.string().refine(value => Array.from(value).length >= 1).optional(), | |
| 98 | 98 | "shapes": z.array(ShapeSchema).optional(), |
| 99 | 99 | }); |
| 100 | 100 | export type Berry = z.infer<typeof BerrySchema>; |
Test case
1 generated file · +1 −1test/inputs/schema/schema-constraints.schema
Mschema-typescript-zoddefault / TopLevel.ts+1 −1
| @@ -2,7 +2,7 @@ import * as z from "zod"; | ||
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | export const TopLevelSchema = z.object({ |
| 5 | - "minMaxLength": z.string().min(5).max(5), | |
| 5 | + "minMaxLength": z.string().refine(value => Array.from(value).length >= 5).refine(value => Array.from(value).length <= 5), | |
| 6 | 6 | "percent": z.number().min(0).max(1), |
| 7 | 7 | }); |
| 8 | 8 | export type TopLevel = z.infer<typeof TopLevelSchema>; |
Test case
1 generated file · +9 −0test/inputs/typescript-zod/unicode-codepoint-length.schema
Aschema-typescript-zoddefault / TopLevel.ts+9 −0
| @@ -0,0 +1,9 @@ | ||
| 1 | +import * as z from "zod"; | |
| 2 | + | |
| 3 | + | |
| 4 | +export const TopLevelSchema = z.object({ | |
| 5 | + "exact": z.string().regex(new RegExp("^[^!]+$")).refine(value => Array.from(value).length >= 2).refine(value => Array.from(value).length <= 2), | |
| 6 | + "maximum": z.string().refine(value => Array.from(value).length <= 1), | |
| 7 | + "minimum": z.string().refine(value => Array.from(value).length >= 2), | |
| 8 | +}); | |
| 9 | +export type TopLevel = z.infer<typeof TopLevelSchema>; |
No generated files match these filters.