Skip to content

Conversation

@frenchy64
Copy link
Collaborator

:union and :merge don't work well with 0 and 1 children.

For 1 child, they don't propagate options to the child. This happens because the reduce call in -reducing returns init, which is a ?schema.

  • this pr ensures options are always propagated

For 0 children, deref'ing returns nil. This is because the reduce call in -reducing is passed nil init.

  • this pr adds checks for non-empty children to :merge and :union
  • fallback error for other users of -reducing
(m/form (m/deref-all (m/schema [:merge [:merge :map]] {:registry (merge (mu/schemas) (m/default-schemas))})))
; (err) Execution error (ExceptionInfo) at malli.core/-exception (core.cljc:157).
; (err) :malli.core/invalid-schema

(m/deref (m/schema :merge {:registry (merge (mu/schemas) (m/default-schemas))}))
;=> nil

@frenchy64 frenchy64 marked this pull request as ready for review December 11, 2024 01:01
@frenchy64 frenchy64 requested a review from ikitommi December 11, 2024 01:12
@ikitommi ikitommi merged commit 440de1b into metosin:master Dec 12, 2024
13 checks passed
@ikitommi
Copy link
Member

Thanks!

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.

2 participants