-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from epigram5-9/feat/FE-68
FE-68 ✨ 회원가입 페이지 유효성 검사
- Loading branch information
Showing
2 changed files
with
61 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import z from 'zod'; | ||
|
||
const PWD_VALIDATION = /^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{8,}$/; | ||
export const PostSignUpRequest = z | ||
.object({ | ||
email: z.string().min(1, { message: '이메일은 필수 입력입니다.' }).email({ message: '이메일 형식으로 작성해 주세요.' }), | ||
password: z | ||
.string() | ||
.min(1, { message: '비밀번호는 필수 입력입니다.' }) | ||
.min(8, { message: '비밀번호는 최소 8자 이상입니다.' }) | ||
.regex(PWD_VALIDATION, { message: '비밀번호는 숫자, 영문, 특수문자로만 가능합니다.' }), | ||
passwordConfirmation: z.string().min(1, { message: '비밀번호 확인을 입력해주세요.' }), | ||
nickname: z.string().min(1, { message: '닉네임은 필수 입력입니다.' }).max(20, { message: '닉네임은 최대 20자까지 가능합니다.' }), | ||
}) | ||
.refine((data) => data.password === data.passwordConfirmation, { | ||
message: '비밀번호가 일치하지 않습니다.', | ||
path: ['passwordConfirmation'], | ||
}); | ||
|
||
export type PostSignUpRequestType = z.infer<typeof PostSignUpRequest>; |