refactor(user-register): showing validation
This commit is contained in:
+20
-13
@@ -1,18 +1,25 @@
|
||||
import * as z from 'zod'
|
||||
|
||||
export const SignupFormSchema = z.object({
|
||||
name: z
|
||||
.string()
|
||||
.min(2, { error: 'Name must be at least 2 characters long.' })
|
||||
.trim(),
|
||||
email: z.email({ error: 'Please enter a valid email.' }).trim(),
|
||||
password: z
|
||||
.string()
|
||||
.min(5, { error: 'Be at least 5 characters long' })
|
||||
.regex(/[a-zA-Z]/, { error: 'Contain at least one letter.' })
|
||||
.regex(/[0-9]/, { error: 'Contain at least one number.' })
|
||||
.trim(),
|
||||
})
|
||||
export const SignupFormSchema = z
|
||||
.object({
|
||||
full_name: z
|
||||
.string()
|
||||
.min(3, { error: 'Name must be at least 3 characters long.' })
|
||||
.trim(),
|
||||
email: z.email({ error: 'Please enter a valid email.' }).trim(),
|
||||
password: z
|
||||
.string()
|
||||
.min(6, { error: 'Be at least 6 characters long' })
|
||||
.regex(/[a-zA-Z]/, { error: 'Contain at least one letter.' })
|
||||
.regex(/[0-9]/, { error: 'Contain at least one number.' })
|
||||
.trim(),
|
||||
confirm_password: z
|
||||
.string()
|
||||
})
|
||||
.refine((data) => data.password === data.confirm_password, {
|
||||
message: 'passwordMismatchErrorMessage',
|
||||
path: ['confirm_password'],
|
||||
});
|
||||
|
||||
export type FormState =
|
||||
| {
|
||||
|
||||
Reference in New Issue
Block a user