New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
:m/default for :multi #391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
src/malli/core.cljc
Outdated
@@ -1087,7 +1087,8 @@ | |||
{:keys [children entries forms]} (-parse-entries children opts' options) | |||
form (-create-form type properties forms) | |||
dispatch (eval (:dispatch properties) options) | |||
dispatch-map (->> (for [[k s] entries] [k s]) (into {}))] | |||
dispatch-map (->> (for [[k s] entries] [k s]) (into {})) | |||
finder (fn [{:keys [:m/default] :as m}] (fn [x] (m x default)))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[aside] TIL you can destructure & reuse keys like that.
(m/form schema))))) | ||
(m/form schema)))) | ||
|
||
(let [schema [:multi {:dispatch first} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Could test that dispatching :m/default
works both with {:dispatch :type}
and {:dispatch first}
.
I vote for using |
Good catch. Looks like grouped keywords can be too opinionating especially going forward with such a highly common prefix like |
Exactly. Also, there even is some prior use of that in Malli itself already with the various options for |
|
Default branch with
:m/default
: