@@ -38,7 +38,7 @@ export const slugSchema = z
3838 'The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug' ,
3939 } )
4040 . max ( MAX_SLUG_LENGTH , {
41- message : `slug can be max ${ MAX_SLUG_LENGTH } characters long` ,
41+ message : `The slug can be max ${ MAX_SLUG_LENGTH } characters long` ,
4242 } ) ;
4343
4444/** Schema for a general description property */
@@ -105,7 +105,7 @@ export function metaSchema(options?: {
105105export const filePathSchema = z
106106 . string ( )
107107 . trim ( )
108- . min ( 1 , { message : 'path is invalid' } ) ;
108+ . min ( 1 , { message : 'The path is invalid' } ) ;
109109
110110/** Schema for a fileNameSchema */
111111export const fileNameSchema = z
@@ -114,7 +114,7 @@ export const fileNameSchema = z
114114 . regex ( filenameRegex , {
115115 message : `The filename has to be valid` ,
116116 } )
117- . min ( 1 , { message : 'file name is invalid' } ) ;
117+ . min ( 1 , { message : 'The file name is invalid' } ) ;
118118
119119/** Schema for a positiveInt */
120120export const positiveIntSchema = z . number ( ) . int ( ) . positive ( ) ;
@@ -172,19 +172,21 @@ export function scorableSchema<T extends ReturnType<typeof weightedRefSchema>>(
172172 slug : slugSchema . describe ( 'Human-readable unique ID, e.g. "performance"' ) ,
173173 refs : z
174174 . array ( refSchema )
175- . min ( 1 )
175+ . min ( 1 , { message : 'In a category, there has to be at least one ref' } )
176176 // refs are unique
177177 . refine (
178178 refs => ! duplicateCheckFn ( refs ) ,
179179 refs => ( {
180180 message : duplicateMessageFn ( refs ) ,
181181 } ) ,
182182 )
183- // categories weights are correct
184- . refine ( hasNonZeroWeightedRef , ( ) => ( {
185- message :
186- 'In a category there has to be at least one ref with weight > 0' ,
187- } ) ) ,
183+ // category weights are correct
184+ . refine ( hasNonZeroWeightedRef , refs => {
185+ const affectedRefs = refs . map ( ref => ref . slug ) . join ( ', ' ) ;
186+ return {
187+ message : `In a category, there has to be at least one ref with weight > 0. Affected refs: ${ affectedRefs } ` ,
188+ } ;
189+ } ) ,
188190 } ,
189191 { description } ,
190192 ) ;
0 commit comments