Add ClassSchedule and Course schemas with validation using zod#1
Merged
Conversation
NaoCoding
requested changes
Sep 5, 2025
| @@ -0,0 +1,14 @@ | |||
| import { z } from 'zod'; | |||
|
|
|||
| export const route = (classScheduleId: string) => `/course/${classScheduleId}`; | |||
Contributor
There was a problem hiding this comment.
This is strange. You should not make the ClassSchedule and Course possess the same route. It will potentially cause issues.
| course_department: z.string().min(1).max(32).describe('Course department'), | ||
| course_time: z.array( | ||
| z.object({ | ||
| start: z.string().regex(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)-([01]\d|2[0-3]):([0-5]\d)$/).describe('Start time in format <Weekday>-<hour>:<minute> ex: Mon-09:00'), |
Contributor
There was a problem hiding this comment.
I believe it won't be like this if lint?
NaoCoding
approved these changes
Sep 5, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces two new schema definitions using Zod for class schedules and courses, providing strong typing and validation for these entities. These schemas will help ensure data integrity and consistency across the application.
Class Schedule Schema:
ClassScheduleschema insrc/lib/schema/ClassSchedule.tswith fields for UUID, name, year, semester, visibility, and course UUIDs.Course Schema:
CourseSchemainsrc/lib/schema/Course.tswith detailed validation for course properties such as classroom, year, semester, credit, names, provider, department, schedule, last update time, EMI status, category, student count, URL, other info, and existence.