This PR adds an optional :coercions metadata key that holds a map containing coercions.
When present, the coercions are merged into the default coercions map.
Custom coercions can be useful for transforming incoming params.
For more info on usage see the documentation changes in the PR.
Rationale
When a key is present, ring's nested-params middleware turns it into a map:
This PR adds an optional
:coercions
metadata key that holds a map containing coercions. When present, the coercions are merged into the default coercions map. Custom coercions can be useful for transforming incoming params. For more info on usage see the documentation changes in the PR.Rationale
When a key is present, ring's nested-params middleware turns it into a map:
Since the ring/nested-params middleware doesn't do parts matching like rack's nested params, a key is mandatory to match parts:
The mandatory key turns the result into maps:
In this case we only care about the values as a vector. Schema coercion
map->vector
(via, say, vals) would be helpful in this case.