@@ -6,7 +6,7 @@ import type {
66 ContentDefinition ,
77 RootDefinition ,
88} from '@croct/content-model/definition/definition' ;
9- import type { Content , PrimitiveValue } from '@croct/content-model/content/content' ;
9+ import type { Content , ListItem , PrimitiveValue } from '@croct/content-model/content/content' ;
1010import type { JsonValue } from '@croct/json' ;
1111import type { CreateResourceOptions } from '@/application/template/action/createResourceAction' ;
1212import type {
@@ -215,13 +215,19 @@ const structureContentSchema = z.strictObject({
215215 attributes : z . record ( z . string ( ) , z . lazy ( ( ) : ZodType < Content > => contentSchema ) ) ,
216216} ) satisfies ZodType < Content < 'structure' > > ;
217217
218+ const labeledItemSchema : ZodType < ListItem < Content > > = z . lazy (
219+ ( ) => z . discriminatedUnion ( 'type' , [
220+ textContentSchema . extend ( { label : z . string ( ) . optional ( ) } ) ,
221+ numberContentSchema . extend ( { label : z . string ( ) . optional ( ) } ) ,
222+ booleanContentSchema . extend ( { label : z . string ( ) . optional ( ) } ) ,
223+ structureContentSchema . extend ( { label : z . string ( ) . optional ( ) } ) ,
224+ listContentSchema . extend ( { label : z . string ( ) . optional ( ) } ) ,
225+ ] ) ,
226+ ) ;
227+
218228const listContentSchema = z . strictObject ( {
219229 type : z . literal ( 'list' ) ,
220- items : z . array ( z . lazy (
221- ( ) : ZodType < Content > => z . intersection ( contentSchema , z . object ( {
222- label : z . string ( ) . optional ( ) ,
223- } ) ) ,
224- ) ) ,
230+ items : z . array ( labeledItemSchema ) ,
225231} ) satisfies ZodType < Content < 'list' > > ;
226232
227233const contentSchema = z . discriminatedUnion ( 'type' , [
0 commit comments