3 ms·
I think all of those problems are only true when you try to do coercion with custom conformers. Which is not the intended use of conformers. Conformers are mea
by didibus 6y ago
I think all of those problems are only true when you try to do coercion with custom conformers. Which is not the intended use of conformers.
Conformers are meant to parse the data when there are multiple possibility of what something can validate against, the conformer will disambiguate and return a result that tells you which path was chosen.
Coercion is not supported as part of Spec, you're expected to do that seperatly either before or after validating/conforming.
- jwr 6y agoYes, that was largely my point. Many people (me included) assume that s/conform is a kind of coercion, which it is not. Not all of the above problems are due to coercion, but the majority are. To be clear: I'm not complaining here, I find spec to be very useful and I like it, just pointing out traps for the unwary.
- didibus 6y agoYa fair enough, I've definitely seen a lot of people think conforming is meant for coercion. But it's not, it's only meant for disambiguating the chosen path (when multiple are possible) for validation.
- zcam 6y agoThere are a few libraries that make it possible without abusing conformers, one of which is https://github.com/exoscale/coax https://github.com/exoscale/coax
- didibus 6y agoLooks nice, I knew of spec-coerce, but not coax.