@@ -442,6 +442,26 @@ export const wrappedParamsSchema = z.object({
442442 height : dimensionParam ( 'height' , 80 , 800 ) ,
443443} ) ;
444444
445+ export const compareParamsSchema = z
446+ . object ( {
447+ user1 : z
448+ . string ( { error : 'Missing user1 parameter' } )
449+ . trim ( )
450+ . min ( 1 , { message : 'user1 is required' } )
451+ . max ( 39 , { message : 'GitHub username cannot exceed 39 characters' } )
452+ . regex ( GITHUB_USERNAME_REGEX , { message : 'Invalid GitHub username for user1' } ) ,
453+ user2 : z
454+ . string ( { error : 'Missing user2 parameter' } )
455+ . trim ( )
456+ . min ( 1 , { message : 'user2 is required' } )
457+ . max ( 39 , { message : 'GitHub username cannot exceed 39 characters' } )
458+ . regex ( GITHUB_USERNAME_REGEX , { message : 'Invalid GitHub username for user2' } ) ,
459+ } )
460+ . refine ( ( data ) => data . user1 . toLowerCase ( ) !== data . user2 . toLowerCase ( ) , {
461+ message : 'Cannot compare a user with themselves.' ,
462+ path : [ 'user2' ] ,
463+ } ) ;
464+
445465export const notifyPostSchema = z . object ( {
446466 username : z
447467 . string ( { error : 'Username is required.' } )
@@ -490,5 +510,6 @@ export type GithubParams = z.infer<typeof githubParamsSchema>;
490510export type OgParams = z . infer < typeof ogParamsSchema > ;
491511export type StatsParams = z . infer < typeof statsParamsSchema > ;
492512export type WrappedParams = z . infer < typeof wrappedParamsSchema > ;
513+ export type CompareParams = z . infer < typeof compareParamsSchema > ;
493514export type NotifyPostParams = z . infer < typeof notifyPostSchema > ;
494515export type NotifyGetParams = z . infer < typeof notifyGetSchema > ;
0 commit comments