generated from mantinedev/next-pages-template
-
-
Notifications
You must be signed in to change notification settings - Fork 286
/
user.ts
53 lines (46 loc) · 1.45 KB
/
user.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { z } from 'zod';
import { CustomErrorParams } from '~/utils/i18n-zod-resolver';
export const minPasswordLength = 8;
export const passwordSchema = z
.string()
.min(minPasswordLength)
.max(100)
.refine((value) => /[0-9]/.test(value))
.refine((value) => /[a-z]/.test(value))
.refine((value) => /[A-Z]/.test(value))
.refine((value) => /[$&+,:;=?@#|'<>.^*()%!-]/.test(value));
export const signInSchema = z.object({
name: z.string(),
password: z.string(),
});
export const signUpFormSchema = z
.object({
username: z.string().min(3),
password: passwordSchema,
passwordConfirmation: z.string().min(minPasswordLength),
})
.refine((data) => data.password === data.passwordConfirmation, {
params: {
i18n: { key: 'passwordMatch' },
} satisfies CustomErrorParams,
path: ['passwordConfirmation'],
});
export const createNewUserSchema = z.object({
username: z.string(),
email: z.string().email().optional(),
password: passwordSchema,
});
export const colorSchemeParser = z
.enum(['light', 'dark', 'environment'])
.default('environment')
.catch('environment');
export const updateSettingsValidationSchema = z.object({
defaultBoard: z.string(),
language: z.string(),
firstDayOfWeek: z.enum(['monday', 'saturday', 'sunday']),
disablePingPulse: z.boolean(),
replaceDotsWithIcons: z.boolean(),
searchTemplate: z.string().nonempty().max(256),
openSearchInNewTab: z.boolean(),
autoFocusSearch: z.boolean(),
});