File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,24 @@ export const workBookSchema = z.object({
72
72
workBookType : z . nativeEnum ( WorkBookType ) ,
73
73
urlSlug : z
74
74
. string ( )
75
- . min ( 0 , { message : '' } )
76
- . max ( 30 , { message : '30文字になるまで削除してください' } ) // 問題集(カリキュラムと解法別)をURLで識別するためのオプション。a-z、0-9、(-)ハイフンのみ使用可能。例: bfs、dfs、dp、union-find、2-sat。
77
- . transform ( ( value ) => ( value === '' ? undefined : value . toLowerCase ( ) ) )
75
+ . nullable ( )
76
+ . optional ( )
77
+ . refine (
78
+ ( value ) => {
79
+ // Allow empty string, null, or undefined
80
+ if ( value === '' || value === null || value === undefined ) {
81
+ return true ;
82
+ }
83
+ return value . length <= 30 ;
84
+ } ,
85
+ { message : '30文字以下になるまで削除してください' } ,
86
+ )
87
+ . transform ( ( value ) =>
88
+ value === '' || value === null || value === undefined ? undefined : value . toLowerCase ( ) ,
89
+ )
78
90
. refine ( ( value ) => value === undefined || isValidUrlSlug ( value ) , {
79
91
message : '半角英小文字、数字、ハイフンのみ使用可能です' ,
80
- } )
81
- . optional ( ) ,
92
+ } ) ,
82
93
workBookTasks : z
83
94
. array ( workBookTaskSchema )
84
95
. min ( 1 , { message : '1問以上登録してください' } )
You can’t perform that action at this time.
0 commit comments