1+ import { z } from "zod" ;
2+
3+ export const Password = z
4+ . string ( )
5+ . min ( 8 , "Password must be at least 8 characters." )
6+ . max ( 70 , "Password must be at most 70 characters." )
7+ . refine ( val => / [ A - Z ] / . test ( val ) , {
8+ error : "Password must contain at least one uppercase letter." ,
9+ } )
10+ . refine ( val => / [ 0 - 9 ] / . test ( val ) , {
11+ error : "Password must contain at least one number." ,
12+ } )
13+ . refine ( val => / [ ^ A - Z a - z 0 - 9 ] .* [ ^ A - Z a - z 0 - 9 ] / . test ( val ) , {
14+ error : "Password must contain at least two special characters." ,
15+ } ) ;
16+ export type Password = z . infer < typeof Password > ;
17+
18+ export const User = z . object ( {
19+ id : z . uuid ( ) ,
20+ email : z . email ( ) ,
21+ name : z . string ( ) . max ( 100 ) ,
22+ role : z . enum ( [ "student" , "faculty" , "admin" ] )
23+ } ) ;
24+ export type User = z . infer < typeof User > ;
25+
26+ export const Term = z . object ( {
27+ id : z . uuid ( ) ,
28+ code : z . string ( ) . max ( 3 ) ,
29+ starts_at : z . iso . datetime ( ) ,
30+ ends_at : z . iso . datetime ( ) ,
31+ } ) ;
32+ export type Term = z . infer < typeof Term > ;
33+
34+ export const Course = z . object ( {
35+ id : z . uuid ( ) ,
36+ course_code : z . string ( ) . max ( 20 ) ,
37+ course_name : z . string ( ) . max ( 100 ) ,
38+ description : z . string ( ) . max ( 500 ) . nullable ( ) ,
39+ } ) ;
40+ export type Course = z . infer < typeof Course > ;
41+
42+ export const Section = z . object ( {
43+ id : z . uuid ( ) ,
44+ code : z . string ( ) . length ( 5 ) ,
45+ instructor_id : z . uuid ( ) . nullable ( ) ,
46+ course_id : z . uuid ( ) ,
47+ term_id : z . uuid ( ) ,
48+ } ) ;
49+ export type Section = z . infer < typeof Section > ;
0 commit comments