-
Notifications
You must be signed in to change notification settings - Fork 215
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
:tuple requires vector #734
Comments
Hi! I guess tuples should be vectors by design. README says:
I'm not sure what is the reason for this (perf? implementation complexity?) but maybe @ikitommi can chime in. :) However, one option is to use sequence schema instead. |
perf, of course :) you can easily add a custom transformer in user space that does the transforming for tuples, relevant helpers exists already, see: https://github.com/metosin/malli/blob/master/src/malli/transform.cljc#L416-L422. PR to add |
Shortly after I posted, I learned that the collection could be empty, so a sequence schema is better for my use case lol. Thanks for mentioning it anyway. Still glad I posted!
Sure thing! Thanks for pointing that out. I'll write it up tonight. |
PR merged, thanks! For ease of use, I think it would be good to have a new built-in transformer that would have this as built-in (e.g. string + collections). But, it's another issue. Closing this one. |
Hey there! I just ran into an issue where using
mt/strip-extra-keys-transformer
wasn't working because I had[:tuple OtherSchema]
and was providing a seq:(OtherSchema)
. I'm not using any Malli validation yet (planned but currently relying on json schema validation) which may have caught this, but it seems worth considering changing. I'd prefer to not have to call(m/encode Example (vec obj) mt/strip-extra-keys-transformer)
just to be sure that I'm providing a vector, as sometimes I'm transforming straight from a database call and the output is a seq instead of a vector.Thanks so much!
The text was updated successfully, but these errors were encountered: