Repository navigation
Closed
Labels
bugSomething isn't working
Description
Report a bug
🔎 Search Terms
validation fail
🧩 Context
System:
OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (16) x64 Intel(R) Xeon(R) W-11955M CPU @ 2.60GHz
Memory: 3.26 GB / 15.23 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
Binaries:
Node: 20.18.3 - /usr/local/bin/node
Yarn: 1.22.22 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
npmPackages:
@ark/schema: 0.44.4
@ark/util: 0.44.4
arktype: ^2.1.9 => 2.1.9
typescript: ^5.5.4 => 5.6.2
🧑💻 Repro
const componentModule = type.module({
container: {
type: "'container'",
content: "component",
},
flexbox: {
type: "'flexbox'",
items: "component",
},
tabsItem: {
id: "string",
title: "component",
content: "component",
},
tabs: {
type: "'tabs'",
items: "tabsItem[]",
},
singleComponent: "string | flexbox | tabs",
component: "singleComponent | singleComponent[]",
});
const componentSchema = componentModule.component;
const component = {
type: "tabs",
items: [
{
id: "tab-id",
title: "tab-title",
content: [],
},
],
};
componentSchema(component);Here is the validation summary:
must be a string or an array (was {"type":"tabs","items":[{"id":"tab-id","title":"tab-title","content":[]},"tab-title"]}), items must be a string (was an object), items.items must be an object or an array (was missing), items[0] must be items[0] must be a string (was an object) or items[0].items must be an object or an array (was missing) (was {"id":"tab-id","title":"tab-title","content":[]}) or items[1] must be an object (was a string)
Very strange stuff. Validation succeeds if I for example:
- Remove the
containertype alias. - Rename
flexbox.itemstoflexbox.foo. - Rename
tabs.itemstotabs.foo. - Change
items[0].titleto[].
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Type
Projects
- StatusShow more project fieldsDone (merged or closed)
Activity
Stadly commentedon Mar 12, 2025
When I use this data instead:
I get this error:
ssalbdivad commentedon Mar 12, 2025
This is likely a duplicate of #1188 so I'm going to close it and add your repro there so we can be sure we add a test case and fix it.
I'd guess the same
jitlessworkaround is likely to help here as well.fix(schema): track cyclic data per key and object
fix(schema): dispatch interpreted unions on their discriminant
test(type): restore 2.2.7's cyclic realWorld tests
test(type): fold the jitless twins into their tests
docs(type): add CHANGELOG entries for cyclic data and recursive generics