@@ -38,7 +38,7 @@ export const slugSchema = z
38
38
'The slug has to follow the pattern [0-9a-z] followed by multiple optional groups of -[0-9a-z]. e.g. my-slug' ,
39
39
} )
40
40
. 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` ,
42
42
} ) ;
43
43
44
44
/** Schema for a general description property */
@@ -105,7 +105,7 @@ export function metaSchema(options?: {
105
105
export const filePathSchema = z
106
106
. string ( )
107
107
. trim ( )
108
- . min ( 1 , { message : 'path is invalid' } ) ;
108
+ . min ( 1 , { message : 'The path is invalid' } ) ;
109
109
110
110
/** Schema for a fileNameSchema */
111
111
export const fileNameSchema = z
@@ -114,7 +114,7 @@ export const fileNameSchema = z
114
114
. regex ( filenameRegex , {
115
115
message : `The filename has to be valid` ,
116
116
} )
117
- . min ( 1 , { message : 'file name is invalid' } ) ;
117
+ . min ( 1 , { message : 'The file name is invalid' } ) ;
118
118
119
119
/** Schema for a positiveInt */
120
120
export const positiveIntSchema = z . number ( ) . int ( ) . positive ( ) ;
@@ -172,19 +172,21 @@ export function scorableSchema<T extends ReturnType<typeof weightedRefSchema>>(
172
172
slug : slugSchema . describe ( 'Human-readable unique ID, e.g. "performance"' ) ,
173
173
refs : z
174
174
. array ( refSchema )
175
- . min ( 1 )
175
+ . min ( 1 , { message : 'In a category, there has to be at least one ref' } )
176
176
// refs are unique
177
177
. refine (
178
178
refs => ! duplicateCheckFn ( refs ) ,
179
179
refs => ( {
180
180
message : duplicateMessageFn ( refs ) ,
181
181
} ) ,
182
182
)
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
+ } ) ,
188
190
} ,
189
191
{ description } ,
190
192
) ;
0 commit comments