Fix Issue 255's Strict Json Transformer #259
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The method for
walk :or
from spec-tools core was changed.Previously it was reducing over all the spec's items (different specs within the
spec/or
).It was essentialy coercing to a given item and the next given item and so forth and so on.
This caused an
strict-json-transformer
to behave inconsistently.@ikitommi 's comment at issue 178, is implemented here.
The method now coerces to all items, and chooses one based on validity or previous behavior.
Issues with the proposed solution
The main issue is that the behavior of the method changes. As it only applies a particular coercion now.
Testing Composed
In that particular test, the value under keys
["keys" ::c2]
gets coerced to akeyword
.That is not in the
spec
.On the same example
["keys" :c1]
will not get coerced to an int now. But that is how coerce worksas ilustrated here.
Parametrization Matters
Minimal examples have been given for this particular issue. Those have been adapted as tests.
However, the
spec
must be written in a particular way. I find this a major flaw.This is the clearest example.