You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PtrStringOptional2: z.string().refine((val) => [...val].length >= 2, 'String must contain at least 2 character(s)').refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)').optional(),
398
+
PtrString1: z.string().refine((val) => [...val].length >= 2, 'String must contain at least 2 character(s)').refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)'),
399
+
PtrString2: z.string().refine((val) => [...val].length >= 2, 'String must contain at least 2 character(s)').refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)'),
400
+
PtrStringNullable: z.string().refine((val) => [...val].length >= 2, 'String must contain at least 2 character(s)').refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)').nullable(),
401
401
})
402
402
export type User = z.infer<typeof UserSchema>
403
403
@@ -487,7 +487,7 @@ export type OneOfSeparated = z.infer<typeof OneOfSeparatedSchema>
@@ -499,7 +499,7 @@ export type Len = z.infer<typeof LenSchema>
499
499
}
500
500
assert.Equal(t,
501
501
`export const MinSchema = z.object({
502
-
Name: z.string().min(5),
502
+
Name: z.string().refine((val) => [...val].length >= 5, 'String must contain at least 5 character(s)'),
503
503
})
504
504
export type Min = z.infer<typeof MinSchema>
505
505
@@ -511,7 +511,7 @@ export type Min = z.infer<typeof MinSchema>
511
511
}
512
512
assert.Equal(t,
513
513
`export const MaxSchema = z.object({
514
-
Name: z.string().max(5),
514
+
Name: z.string().refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)'),
515
515
})
516
516
export type Max = z.infer<typeof MaxSchema>
517
517
@@ -523,7 +523,7 @@ export type Max = z.infer<typeof MaxSchema>
523
523
}
524
524
assert.Equal(t,
525
525
`export const MinMaxSchema = z.object({
526
-
Name: z.string().min(3).max(7),
526
+
Name: z.string().refine((val) => [...val].length >= 3, 'String must contain at least 3 character(s)').refine((val) => [...val].length <= 7, 'String must contain at most 7 character(s)'),
527
527
})
528
528
export type MinMax = z.infer<typeof MinMaxSchema>
529
529
@@ -535,7 +535,7 @@ export type MinMax = z.infer<typeof MinMaxSchema>
535
535
}
536
536
assert.Equal(t,
537
537
`export const GtSchema = z.object({
538
-
Name: z.string().min(6),
538
+
Name: z.string().refine((val) => [...val].length > 5, 'String must contain at least 6 character(s)'),
539
539
})
540
540
export type Gt = z.infer<typeof GtSchema>
541
541
@@ -547,7 +547,7 @@ export type Gt = z.infer<typeof GtSchema>
547
547
}
548
548
assert.Equal(t,
549
549
`export const GteSchema = z.object({
550
-
Name: z.string().min(5),
550
+
Name: z.string().refine((val) => [...val].length >= 5, 'String must contain at least 5 character(s)'),
551
551
})
552
552
export type Gte = z.infer<typeof GteSchema>
553
553
@@ -559,7 +559,7 @@ export type Gte = z.infer<typeof GteSchema>
559
559
}
560
560
assert.Equal(t,
561
561
`export const LtSchema = z.object({
562
-
Name: z.string().max(4),
562
+
Name: z.string().refine((val) => [...val].length < 5, 'String must contain at most 4 character(s)'),
563
563
})
564
564
export type Lt = z.infer<typeof LtSchema>
565
565
@@ -571,7 +571,7 @@ export type Lt = z.infer<typeof LtSchema>
571
571
}
572
572
assert.Equal(t,
573
573
`export const LteSchema = z.object({
574
-
Name: z.string().max(5),
574
+
Name: z.string().refine((val) => [...val].length <= 5, 'String must contain at most 5 character(s)'),
575
575
})
576
576
export type Lte = z.infer<typeof LteSchema>
577
577
@@ -1456,7 +1456,7 @@ export type Lte = z.infer<typeof LteSchema>
Map: z.record(z.string(), z.string().refine((val) => [...val].length >= 2, 'String must contain at least 2 character(s)')).nullable(),
1460
1460
})
1461
1461
export type Dive1 = z.infer<typeof Dive1Schema>
1462
1462
@@ -1467,7 +1467,7 @@ export type Dive1 = z.infer<typeof Dive1Schema>
1467
1467
}
1468
1468
assert.Equal(t,
1469
1469
`export const Dive2Schema = z.object({
1470
-
Map: z.record(z.string(), z.string().min(3)).refine((val) => Object.keys(val).length >= 2, 'Map too small').array(),
1470
+
Map: z.record(z.string(), z.string().refine((val) => [...val].length >= 3, 'String must contain at least 3 character(s)')).refine((val) => Object.keys(val).length >= 2, 'Map too small').array(),
1471
1471
})
1472
1472
export type Dive2 = z.infer<typeof Dive2Schema>
1473
1473
@@ -1478,7 +1478,7 @@ export type Dive2 = z.infer<typeof Dive2Schema>
1478
1478
}
1479
1479
assert.Equal(t,
1480
1480
`export const Dive3Schema = z.object({
1481
-
Map: z.record(z.string().min(3), z.string().max(4)).refine((val) => Object.keys(val).length >= 2, 'Map too small').array(),
1481
+
Map: z.record(z.string().refine((val) => [...val].length >= 3, 'String must contain at least 3 character(s)'), z.string().refine((val) => [...val].length <= 4, 'String must contain at most 4 character(s)')).refine((val) => Object.keys(val).length >= 2, 'Map too small').array(),
0 commit comments