Skip to content

Commit

Permalink
Edited the validation texts for the forms
Browse files Browse the repository at this point in the history
  • Loading branch information
rbakkalian committed May 13, 2024
1 parent 94db590 commit 12a21c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions frontend/src/pages/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type LoginForm = {
};

export const LoginSchema: ZodType<LoginForm> = z.object({
username: z.string().min(4).max(30),
password: z.string().min(8).max(30),
username: z.string().min(4, "Minimum length should be 4").max(30, "Maximum length should be 30"),
password: z.string().min(8, "Minimum length should be 8").max(30, "Minimum length should be 30"),
});

export default function Login() {
Expand Down
17 changes: 12 additions & 5 deletions frontend/src/pages/Auth/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$

export const RegisterSchema: ZodType<RegisterForm> = z
.object({
username: z.string().min(4).max(30),
password: z.string().min(8).max(30).regex(passwordRegex),
confirmPassword: z.string().min(8).max(30).regex(passwordRegex),
firstName: z.string().min(3).max(30),
lastName: z.string().min(3).max(30),
username: z.string().min(4, "Minimum length should be 4").max(30, "Minimum length should be 30"),
password: z
.string()
.min(8, "Minimum length should be 8")
.max(30, "Minimum length should be 30")
.regex(
passwordRegex,
"Password should contain at least 1 lowercase and 1 uppercase letters and 1 special character and no spaces",
),
confirmPassword: z.string().regex(passwordRegex, "Password does not match!"),
firstName: z.string().min(3, "Minimum length should be 3").max(30, "Minimum length should be 30"),
lastName: z.string().min(3, "Minimum length should be 3").max(30, "Minimum length should be 30"),
premium: z.boolean(),
})
.refine((data) => data.password === data.confirmPassword, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ const getEditSchema = (title: string) =>
z.object({
title: z
.string()
.min(3)
.max(30)
.refine((value) => value !== title, "it cannot be like the old one"),
.min(3, "Minimum length should be 3")
.max(30, "Maximum length should be 30")
.refine((value) => value !== title, "Cannot be the same as the previous title!"),
});

function EditConversationModal({ conversation, unSet }: EditModalProps) {
Expand Down

0 comments on commit 12a21c7

Please sign in to comment.