Skip to content

[FIX] owl-core: add .toShape() to reuse a schema as props#1967

Merged
mcm-odoo merged 1 commit into
masterfrom
issue-1966-ged
Jul 6, 2026
Merged

[FIX] owl-core: add .toShape() to reuse a schema as props#1967
mcm-odoo merged 1 commit into
masterfrom
issue-1966-ged

Conversation

@ged-odoo

@ged-odoo ged-odoo commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Passing a composed schema (e.g. t.and([...]) or t.object({...})) to props() failed validation with a spurious missingKeys: ["optional"] error: a validator is a function carrying an .optional method, so props() mistook it for a plain {key: Type} shape and Object.keys returned ["optional"].

Rather than teach props() to unwrap a validator, object schemas (t.object, t.strictObject) and intersections of them (t.and) now expose a .toShape() method returning the {key: type} map they were built from (t.and merges the shapes of its members). props() is left unchanged; a reusable schema drives props via props(Schema.toShape()), e.g. applyDefaults(props(Schema.toShape()), Schema).

closes #1966

Passing a composed schema (e.g. `t.and([...])` or `t.object({...})`) to
`props()` failed validation with a spurious `missingKeys: ["optional"]`
error: a validator is a function carrying an `.optional` method, so
`props()` mistook it for a plain `{key: Type}` shape and `Object.keys`
returned `["optional"]`.

Rather than teach `props()` to unwrap a validator, object schemas
(`t.object`, `t.strictObject`) and intersections of them (`t.and`) now
expose a `.toShape()` method returning the `{key: type}` map they were
built from (`t.and` merges the shapes of its members). `props()` is left
unchanged; a reusable schema drives props via `props(Schema.toShape())`,
e.g. `applyDefaults(props(Schema.toShape()), Schema)`.

closes #1966
@ged-odoo ged-odoo changed the title [FIX] owl-runtime: accept a type validator schema in props() [FIX] owl-core: add .toShape() to reuse a schema as props Jul 6, 2026
@mcm-odoo mcm-odoo merged commit 38a522c into master Jul 6, 2026
2 checks passed
@mcm-odoo mcm-odoo deleted the issue-1966-ged branch July 6, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

applyDefaults on props trigger a validation error on "optional" property

2 participants