Skip to content

Commit 03755ef

Browse files
committed
chore: add interface test cases
1 parent 3574275 commit 03755ef

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

samples/custom/interface.valibot.ts

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {
2+
InferOutput,
3+
array,
4+
boolean,
5+
email,
6+
literal,
7+
number,
8+
object,
9+
pipe,
10+
string,
11+
union,
12+
} from 'valibot'
13+
14+
export const Interface_BaseSubModel1 = object({
15+
description: string(),
16+
createdAt: string(),
17+
updatedAt: string(),
18+
})
19+
export type Interface_BaseSubModel1 = InferOutput<typeof Interface_BaseSubModel1>
20+
21+
export const Interface_BaseSubModel2 = object({
22+
description: string(),
23+
createdAt: string(),
24+
updatedAt: string(),
25+
})
26+
export type Interface_BaseSubModel2 = InferOutput<typeof Interface_BaseSubModel2>
27+
28+
export const Interface_BaseSubModel3 = object({
29+
name: string(),
30+
age: number(),
31+
isActive: boolean(),
32+
})
33+
export type Interface_BaseSubModel3 = InferOutput<typeof Interface_BaseSubModel3>
34+
35+
export const Interface_BaseSubModel4 = object({
36+
title: string(),
37+
tags: array(string()),
38+
published: boolean(),
39+
})
40+
export type Interface_BaseSubModel4 = InferOutput<typeof Interface_BaseSubModel4>
41+
42+
export const Interface_BaseSubModel5 = object({
43+
id: number(),
44+
email: pipe(string(), email()),
45+
role: union([literal('admin'), literal('user'), literal('guest')]),
46+
})
47+
export type Interface_BaseSubModel5 = InferOutput<typeof Interface_BaseSubModel5>
48+
49+
export const Interface_ComplexUnion = union([
50+
Interface_BaseSubModel1,
51+
Interface_BaseSubModel2,
52+
Interface_BaseSubModel3,
53+
Interface_BaseSubModel4,
54+
Interface_BaseSubModel5,
55+
])
56+
export type Interface_ComplexUnion = InferOutput<typeof Interface_ComplexUnion>

samples/custom/interface.zod.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { z } from 'zod'
2+
3+
export type Interface_BaseSubModel1 = z.infer<typeof Interface_BaseSubModel1>
4+
export const Interface_BaseSubModel1 = z.object({
5+
description: z.string(),
6+
createdAt: z.string(),
7+
updatedAt: z.string(),
8+
})
9+
10+
export type Interface_BaseSubModel2 = z.infer<typeof Interface_BaseSubModel2>
11+
export const Interface_BaseSubModel2 = z.object({
12+
description: z.string(),
13+
createdAt: z.string(),
14+
updatedAt: z.string(),
15+
})
16+
17+
export const Interface_BaseSubModel3 = z.object({
18+
name: z.string(),
19+
age: z.number(),
20+
isActive: z.boolean(),
21+
})
22+
export type Interface_BaseSubModel3 = z.infer<typeof Interface_BaseSubModel3>
23+
24+
export const Interface_BaseSubModel4 = z.object({
25+
title: z.string(),
26+
tags: z.array(z.string()),
27+
published: z.boolean(),
28+
})
29+
export type Interface_BaseSubModel4 = z.infer<typeof Interface_BaseSubModel4>
30+
31+
export const Interface_BaseSubModel5 = z.object({
32+
id: z.number(),
33+
email: z.string().email(),
34+
role: z.enum(['admin', 'user', 'guest']),
35+
})
36+
export type Interface_BaseSubModel5 = z.infer<typeof Interface_BaseSubModel5>
37+
38+
export const Interface_ComplexUnion = z.union([
39+
Interface_BaseSubModel1,
40+
Interface_BaseSubModel2,
41+
Interface_BaseSubModel3,
42+
Interface_BaseSubModel4,
43+
Interface_BaseSubModel5,
44+
])
45+
export type Interface_ComplexUnion = z.infer<typeof Interface_ComplexUnion>

samples/custom/interface.zod4.ts

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { z } from 'zod4'
2+
3+
export type Interface_BaseSubModel1 = z.infer<typeof Interface_BaseSubModel1>
4+
export const Interface_BaseSubModel1 = z.interface({
5+
description: z.string(),
6+
createdAt: z.string(),
7+
updatedAt: z.string(),
8+
})
9+
10+
export type Interface_BaseSubModel2 = z.infer<typeof Interface_BaseSubModel2>
11+
export const Interface_BaseSubModel2 = z.interface({
12+
description: z.string(),
13+
createdAt: z.string(),
14+
updatedAt: z.string(),
15+
})
16+
17+
export const Interface_BaseSubModel3 = z.interface({
18+
name: z.string(),
19+
age: z.number(),
20+
isActive: z.boolean(),
21+
})
22+
export type Interface_BaseSubModel3 = z.infer<typeof Interface_BaseSubModel3>
23+
24+
export const Interface_BaseSubModel4 = z.interface({
25+
title: z.string(),
26+
tags: z.array(z.string()),
27+
published: z.boolean(),
28+
})
29+
export type Interface_BaseSubModel4 = z.infer<typeof Interface_BaseSubModel4>
30+
31+
export const Interface_BaseSubModel5 = z.interface({
32+
id: z.number(),
33+
email: z.string().email(),
34+
role: z.enum(['admin', 'user', 'guest']),
35+
})
36+
export type Interface_BaseSubModel5 = z.infer<typeof Interface_BaseSubModel5>
37+
38+
export const Interface_ComplexUnion = z.union([
39+
Interface_BaseSubModel1,
40+
Interface_BaseSubModel2,
41+
Interface_BaseSubModel3,
42+
Interface_BaseSubModel4,
43+
Interface_BaseSubModel5,
44+
])
45+
export type Interface_ComplexUnion = z.infer<typeof Interface_ComplexUnion>

0 commit comments

Comments
 (0)