Skip to content

Commit

Permalink
Add list option for select case when object (#60)
Browse files Browse the repository at this point in the history
* Add list option for select case when object

* Fix import

* Add change functions

---------

Co-authored-by: Misode <misoloo64@gmail.com>
  • Loading branch information
Apollounknowndev and misode authored Nov 8, 2024
1 parent 4dfc0e5 commit 5a837ba
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion java/1.21.4/src/schemas/assets/ItemDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
StringNode as RawStringNode,
Mod,
NumberNode,
ChoiceNode,
ObjectNode,
SchemaRegistry,
CollectionRegistry,
Expand Down Expand Up @@ -63,7 +64,18 @@ export function initItemDefinitionSchemas(schemas: SchemaRegistry, collections:
}),
cases: ListNode(
ObjectNode({
when: StringNode(),
when: ChoiceNode([
{
type: 'string',
node: StringNode(),
change: v => Array.isArray(v) && v.length > 0 ? v[0] : ""
},
{
type: 'list',
node: ListNode(StringNode()),
change: v => typeof v === 'string' ? [v] : []
}
]),
model: Reference('item_model')
})
),
Expand Down

0 comments on commit 5a837ba

Please sign in to comment.