You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to set default values? I would like to set certain constraints on incoming parameters while not requiring to fill in any of them, falling back to defaults instead.
The text was updated successfully, but these errors were encountered:
Default values aren't very intuitive in the dry-validation ecosystem. I think the easiest way to handle defaults (for required values) is probably the following. Assuming you have a status that you want to take as an argument with the default of 'processing':
You can also handle a default value using optional(:status).maybe(:str?) and a rule to set it if it's missing, but I think that would take some internal refactoring in order to expose the rules interface within interactor-contracts. The interface was designed prior to the extraction of dry-schema from dry-validation so it doesn't take them into account.
The type system of dry-types is really powerful. I suggest checking it out!
Let me know if that doesn't work for you.
I would also be happy to help coach you through the reworking on the internals of the gem to expose rules if you're interested. I labeled this issue with hacktoberfest because it's something I'm interested in and likely something I will suggest to my team if they are interested in Hacktoberfest.
Is it possible to set default values? I would like to set certain constraints on incoming parameters while not requiring to fill in any of them, falling back to defaults instead.
The text was updated successfully, but these errors were encountered: