forked from Kiranism/next-shadcn-dashboard-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform-schema.ts
39 lines (37 loc) · 1.37 KB
/
form-schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import * as z from 'zod';
export const profileSchema = z.object({
firstname: z
.string()
.min(3, { message: 'Product Name must be at least 3 characters' }),
lastname: z
.string()
.min(3, { message: 'Product Name must be at least 3 characters' }),
email: z
.string()
.email({ message: 'Product Name must be at least 3 characters' }),
contactno: z.coerce.number(),
country: z.string().min(1, { message: 'Please select a category' }),
city: z.string().min(1, { message: 'Please select a category' }),
// jobs array is for the dynamic fields
jobs: z.array(
z.object({
jobcountry: z.string().min(1, { message: 'Please select a category' }),
jobcity: z.string().min(1, { message: 'Please select a category' }),
jobtitle: z
.string()
.min(3, { message: 'Product Name must be at least 3 characters' }),
employer: z
.string()
.min(3, { message: 'Product Name must be at least 3 characters' }),
startdate: z
.string()
.refine((value) => /^\d{4}-\d{2}-\d{2}$/.test(value), {
message: 'Start date should be in the format YYYY-MM-DD'
}),
enddate: z.string().refine((value) => /^\d{4}-\d{2}-\d{2}$/.test(value), {
message: 'End date should be in the format YYYY-MM-DD'
})
})
)
});
export type ProfileFormValues = z.infer<typeof profileSchema>;