@@ -38,39 +38,35 @@ const licenses = Object.keys(UPLOAD_CONSTANTS.licenses) as Readonly<string[]>;
3838export const SongFormSchema = zod . object ( {
3939 allowDownload : zod . boolean ( ) . default ( true ) ,
4040
41- // @ts -ignore
4241 visibility : zod . enum ( visibility ) . default ( 'public' ) ,
4342 title : zod
4443 . string ( )
4544 . max ( UPLOAD_CONSTANTS . title . maxLength , {
46- message : `Title must be shorter than ${ UPLOAD_CONSTANTS . title . maxLength } characters` ,
45+ error : `Title must be shorter than ${ UPLOAD_CONSTANTS . title . maxLength } characters` ,
4746 } )
4847 . min ( 1 , {
49- message : 'Title is required' ,
48+ error : 'Title is required' ,
5049 } ) ,
5150 originalAuthor : zod
5251 . string ( )
5352 . max ( UPLOAD_CONSTANTS . originalAuthor . maxLength , {
54- message : `Original author must be shorter than ${ UPLOAD_CONSTANTS . originalAuthor . maxLength } characters` ,
53+ error : `Original author must be shorter than ${ UPLOAD_CONSTANTS . originalAuthor . maxLength } characters` ,
5554 } )
5655 . min ( 0 ) ,
5756 author : zod . string ( ) . optional ( ) ,
5857 description : zod . string ( ) . max ( UPLOAD_CONSTANTS . description . maxLength , {
59- message : `Description must be less than ${ UPLOAD_CONSTANTS . description . maxLength } characters` ,
58+ error : `Description must be less than ${ UPLOAD_CONSTANTS . description . maxLength } characters` ,
6059 } ) ,
6160 thumbnailData : thumbnailDataSchema ,
6261 customInstruments : zod . array ( zod . string ( ) ) ,
6362 license : zod
64-
65- // @ts -ignore
66- . enum ( licenses , {
63+ . enum ( [ 'none' , ...licenses ] as const )
64+ . refine ( ( v ) => v !== 'none' , {
6765 message : 'Please select a license' ,
6866 } )
69- . refine ( ( value ) => Object . keys ( UPLOAD_CONSTANTS . licenses ) . includes ( value ) )
7067 . default ( UPLOAD_CONSTANTS . license . default ) ,
7168
72- // @ts -ignore
73- category : zod . enum ( categories ) . default ( UPLOAD_CONSTANTS . CATEGORY_DEFAULT ) ,
69+ category : zod . enum ( categories ) . default ( UPLOAD_CONSTANTS . category . default ) ,
7470} ) ;
7571
7672export const uploadSongFormSchema = SongFormSchema . extend ( { } ) ;
0 commit comments