Skip to content

Commit 0152e68

Browse files
committed
refactor: move validation utilities to auth feature and enhance email validation
1 parent 26a5dc9 commit 0152e68

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed
File renamed without changes.

apps/client/src/shared/validation/validation-status.type.ts renamed to apps/client/src/features/auth/validation/validation-status.type.ts

File renamed without changes.

apps/client/src/shared/validation/validation-status.util.ts renamed to apps/client/src/features/auth/validation/validation-status.util.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { ValidationStatusWithMessage } from '@/shared/validation/validation-status.type';
1+
import { z } from 'zod';
2+
3+
import { ValidationStatusWithMessage } from '@/features/auth/validation/validation-status.type';
24

35
export const validateEmail = (email: string): ValidationStatusWithMessage => {
46
if (!email) return { status: 'INITIAL' };
@@ -7,12 +9,18 @@ export const validateEmail = (email: string): ValidationStatusWithMessage => {
79
status: 'INVALID',
810
message: '이메일에 공백이 포함될 수 없습니다.',
911
};
12+
try {
13+
z.string().email().parse(email);
14+
} catch (error) {
15+
return {
16+
status: 'INVALID',
17+
message: '올바른 이메일 형식이 아닙니다.',
18+
};
19+
}
1020
return { status: 'PENDING', message: '유효 여부를 검사 중입니다.' };
1121
};
1222

13-
export const validateNickname = (
14-
nickname: string,
15-
): ValidationStatusWithMessage => {
23+
export const validateNickname = (nickname: string): ValidationStatusWithMessage => {
1624
if (!nickname) return { status: 'INITIAL' };
1725
if (nickname.length < 3 || nickname.length > 20)
1826
return {
@@ -27,9 +35,7 @@ export const validateNickname = (
2735
return { status: 'PENDING', message: '유효 여부를 검사 중입니다.' };
2836
};
2937

30-
export const validatePassword = (
31-
password: string,
32-
): ValidationStatusWithMessage => {
38+
export const validatePassword = (password: string): ValidationStatusWithMessage => {
3339
if (!password) return { status: 'INITIAL' };
3440
if (password.length < 8 || password.length > 20)
3541
return {

0 commit comments

Comments
 (0)