Skip to content

Add ClassSchedule and Course schemas with validation using zod#1

Merged
Darrin-Lin merged 2 commits into
mainfrom
firebase/courses-schema
Sep 5, 2025
Merged

Add ClassSchedule and Course schemas with validation using zod#1
Darrin-Lin merged 2 commits into
mainfrom
firebase/courses-schema

Conversation

@Darrin-Lin
Copy link
Copy Markdown
Member

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:

  • Added ClassSchedule schema in src/lib/schema/ClassSchedule.ts with fields for UUID, name, year, semester, visibility, and course UUIDs.
  • Defined a route helper function for class schedules.

Course Schema:

  • Added CourseSchema in src/lib/schema/Course.ts with 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.
  • Defined a route helper function for courses.

Comment thread src/lib/schema/ClassSchedule.ts Outdated
@@ -0,0 +1,14 @@
import { z } from 'zod';

export const route = (classScheduleId: string) => `/course/${classScheduleId}`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange. You should not make the ClassSchedule and Course possess the same route. It will potentially cause issues.

Comment thread src/lib/schema/Course.ts
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'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it won't be like this if lint?

@Darrin-Lin Darrin-Lin merged commit 3786484 into main Sep 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants