-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add option to add default value to optional properties #646
Comments
This would be great, i.e., this presently doesn't work (whether optional or not)
Funnily enough, decode does the right thing:
|
Are there really a use cases that the schema itself should control how to add the defaults? should it be recursive? Simple solution would be add this option to |
see #668 |
@dharrigan That is working as intended.
|
@ikitommi Transformer level option probably makes sense. I think on the project where I had use for this, I used On Reitit I could also set |
I have a case where I need default values to be added to the maps, even though the properties are optional.
Should be simple to add new condition to
optional
check to look at a new property, like:default/force
or such, and then include default value if that is set, even if the property is optional.https://github.com/metosin/malli/blob/master/src/malli/transform.cljc#L394
#351 #397
Some ideas for the option name
:default/always
:default/missing-key
:default/force
The text was updated successfully, but these errors were encountered: