File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ export type WorkBookBase = {
88 isOfficial : boolean ;
99 isReplenished : boolean ; // カリキュラムの【補充】を識別するために使用
1010 workBookType : WorkBookType ;
11+ urlSlug ?: string ; // 問題集(カリキュラムと解法別)をURLで識別するためのオプション。a-z、0-9、(-)ハイフンのみ使用可能。例: bfs、dfs、dp、union-find、2-sat。
1112 workBookTasks : WorkBookTaskBase [ ] ;
1213} ;
1314
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ const workBookTaskSchema = z.object({
5151 . max ( 50 , { message : '50文字になるまで削除してください' } ) , // FIXME: 上限は暫定値。
5252} ) ;
5353
54+ // TODO: URL用のカラムとバリデーションを追加
5455export const workBookSchema = z . object ( {
5556 authorId : z . string ( ) ,
5657 title : z
@@ -70,6 +71,15 @@ export const workBookSchema = z.object({
7071 isOfficial : z . boolean ( ) ,
7172 isReplenished : z . boolean ( ) , // カリキュラムの【補充】を識別するために使用
7273 workBookType : z . nativeEnum ( WorkBookType ) ,
74+ urlSlug : z
75+ . string ( )
76+ . min ( 0 , { message : '' } )
77+ . max ( 30 , { message : '30文字になるまで削除してください' } ) // 問題集(カリキュラムと解法別)をURLで識別するためのオプション。a-z、0-9、(-)ハイフンのみ使用可能。例: bfs、dfs、dp、union-find、2-sat。
78+ . transform ( ( value ) => ( value === '' ? undefined : value ) )
79+ . refine ( ( value ) => value === undefined || / ^ [ a - z 0 - 9 ] + ( - [ a - z 0 - 9 ] + ) * $ / . test ( value ) , {
80+ message : '半角英小文字、数字、ハイフンのみ使用可能です' ,
81+ } )
82+ . optional ( ) ,
7383 workBookTasks : z
7484 . array ( workBookTaskSchema )
7585 . min ( 1 , { message : '1問以上登録してください' } )
You can’t perform that action at this time.
0 commit comments