-
Notifications
You must be signed in to change notification settings - Fork 3
[feature] 지원서 저장 시 검증 추가 #1221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
seongwon030
merged 2 commits into
develop-fe
from
feature/#1219-application-edit-validation-MOA-666
Feb 21, 2026
Merged
[feature] 지원서 저장 시 검증 추가 #1221
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
71 changes: 71 additions & 0 deletions
71
frontend/src/pages/AdminPage/validation/validateApplicationForm.ts
This file contains hidden or 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,71 @@ | ||
| import { ApplicationFormData, ApplicationFormMode } from '@/types/application'; | ||
|
|
||
| const ALLOWED_EXTERNAL_URLS = [ | ||
| 'https://forms.gle/', | ||
| 'https://docs.google.com/forms', | ||
| 'https://form.naver.com/', | ||
| 'https://naver.me/', | ||
| 'https://everytime.kr/', | ||
| ]; | ||
|
|
||
| export interface ApplicationFormErrors { | ||
| title?: string; | ||
| description?: string; | ||
| questions?: Record<number, string>; | ||
| externalUrl?: string; | ||
| } | ||
|
|
||
| export const validateApplicationForm = ( | ||
| formData: ApplicationFormData, | ||
| mode: ApplicationFormMode, | ||
| externalUrl: string, | ||
| ): ApplicationFormErrors => { | ||
| const errors: ApplicationFormErrors = {}; | ||
|
|
||
| if (!formData.title?.trim()) { | ||
| errors.title = '지원서 제목을 입력해주세요.'; | ||
| } else if (formData.title.length > 50) { | ||
| errors.title = '지원서 제목은 최대 50자까지 입력할 수 있습니다.'; | ||
| } | ||
|
|
||
| if (!formData.description?.trim()) { | ||
| errors.description = '지원서 설명을 입력해주세요.'; | ||
| } else if (formData.description.length > 3000) { | ||
| errors.description = '지원서 설명은 최대 3000자까지 입력할 수 있습니다.'; | ||
| } | ||
|
|
||
| if (mode === ApplicationFormMode.INTERNAL) { | ||
| const questionErrors: Record<number, string> = {}; | ||
|
|
||
| formData.questions?.forEach((q) => { | ||
| if (!q.title.trim()) { | ||
| questionErrors[q.id] = '질문 제목을 입력해주세요.'; | ||
| } else if ( | ||
| (q.type === 'CHOICE' || q.type === 'MULTI_CHOICE') && | ||
| q.items.some((item) => !item.value.trim()) | ||
| ) { | ||
| questionErrors[q.id] = '선택지에 빈 항목이 있습니다.'; | ||
| } | ||
| }); | ||
|
|
||
| if (Object.keys(questionErrors).length > 0) { | ||
| errors.questions = questionErrors; | ||
| } | ||
| } | ||
|
|
||
| if (mode === ApplicationFormMode.EXTERNAL) { | ||
| if (!externalUrl.trim()) { | ||
| errors.externalUrl = '외부 지원서 링크를 입력해주세요.'; | ||
| } else if ( | ||
| !ALLOWED_EXTERNAL_URLS.some((url) => externalUrl.startsWith(url)) | ||
| ) { | ||
| errors.externalUrl = | ||
| 'Google Forms, Naver Form 또는 Everytime 링크여야 합니다.'; | ||
| } | ||
| } | ||
|
|
||
| return errors; | ||
| }; | ||
|
|
||
| export const hasErrors = (errors: ApplicationFormErrors): boolean => | ||
| Object.keys(errors).length > 0; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.