-
Notifications
You must be signed in to change notification settings - Fork 1
Fix/156 일정 검증로직 추가 #157
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
Fix/156 일정 검증로직 추가 #157
Changes from all commits
Commits
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
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
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
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,31 @@ | ||
| import { Schedule } from '@/types/activityDetailType'; | ||
|
|
||
| export function validateSchedules(schedules: Schedule[]) { | ||
| const today = new Date(); | ||
| today.setHours(0, 0, 0, 0); | ||
|
|
||
| for (let i = 0; i < schedules.length; i++) { | ||
| const { date, startTime, endTime } = schedules[i]; | ||
|
|
||
| if (!date || !startTime || !endTime) { | ||
| return `날짜와 시간이 모두 입력되어야 합니다!`; | ||
| } | ||
|
|
||
| const selectedDate = new Date(date); | ||
| if (selectedDate < today) { | ||
| return `오늘보다 이전 날짜는 선택할 수 없습니다!`; | ||
| } | ||
|
|
||
| const [startHour, startMinute] = startTime.split(':').map(Number); | ||
| const [endHour, endMinute] = endTime.split(':').map(Number); | ||
|
|
||
| const startMinutes = startHour * 60 + startMinute; | ||
| const endMinutes = endHour * 60 + endMinute; | ||
|
|
||
| if (startMinutes >= endMinutes) { | ||
| return `종료 시간은 시작 시간보다 늦어야 합니다!`; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
실시간 검증 로직이 사용자 경험을 향상시킵니다.
각 입력 필드에서 즉시 검증을 수행하여 사용자에게 빠른 피드백을 제공하는 것이 좋습니다. 다만 validateSchedules 함수와 검증 로직의 일관성을 유지하는 것을 권장합니다.
중복을 줄이기 위해 isPastDate 로직을 validateSchedules와 통일하는 것을 고려해보세요:
function isPastDate(dateStr: string) { - const selected = new Date(dateStr); - const today = new Date(); - today.setHours(0, 0, 0, 0); - return selected < today; + const selectedDate = new Date(dateStr); + const today = new Date(); + today.setHours(0, 0, 0, 0); + return selectedDate < today; }🤖 Prompt for AI Agents