Skip to content
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

Decoder#validate allowing building the message from the trigger HCursor #1020

Merged
merged 3 commits into from Dec 14, 2018

Conversation

pfcoperez
Copy link
Contributor

Resolves #1019

This PR pretends to enable generating validate messages from the HCursor value which triggered the failure by satisfying the passed predicate.

It overloads the original validate method which now gets implemented by invoking this new implementation.

@pfcoperez pfcoperez force-pushed the feature/custom_validate_message branch from 4f90937 to 9639e66 Compare November 22, 2018 21:38
@pfcoperez pfcoperez force-pushed the feature/custom_validate_message branch from 9639e66 to a152532 Compare November 22, 2018 21:40
@codecov-io
Copy link

codecov-io commented Nov 23, 2018

Codecov Report

Merging #1020 into master will decrease coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1020      +/-   ##
==========================================
- Coverage   85.37%   85.29%   -0.08%     
==========================================
  Files          75       75              
  Lines        2386     2387       +1     
  Branches      174      167       -7     
==========================================
- Hits         2037     2036       -1     
- Misses        349      351       +2
Impacted Files Coverage Δ
.../core/shared/src/main/scala/io/circe/Decoder.scala 92.92% <100%> (-0.29%) ⬇️
...e/generic/extras/decoding/EnumerationDecoder.scala 88.88% <0%> (-11.12%) ⬇️
...scala/io/circe/shapes/LabelledHListInstances.scala 92.59% <0%> (-3.71%) ⬇️
...re/shared/src/main/scala/io/circe/KeyDecoder.scala 97.29% <0%> (-2.71%) ⬇️
...rc/main/scala/io/circe/numbers/BiggerDecimal.scala 90.36% <0%> (ø) ⬆️
...re/shared/src/main/scala/io/circe/JsonNumber.scala 92.4% <0%> (ø) ⬆️
...les/core/shared/src/main/scala/io/circe/Json.scala 79.61% <0%> (+0.63%) ⬆️
...d/src/main/scala/io/circe/NonEmptySeqDecoder.scala 100% <0%> (+8.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e3a589...ca44c79. Read the comment docs.

Thus allowing embedding the error generation function in a block and making the overload seamlessly work with Scala 2.11
@pfcoperez pfcoperez force-pushed the feature/custom_validate_message branch from 98588d0 to ff728ac Compare November 23, 2018 09:53
@travisbrown
Copy link
Member

This looks reasonable to me, thanks! We'll be sure it makes it into 0.11.

@travisbrown travisbrown mentioned this pull request Dec 2, 2018
…e predicate and the errors to be generated by the validation check.
@pfcoperez
Copy link
Contributor Author

pfcoperez commented Dec 5, 2018

@travisbrown As discussed in #1025 (comment) , I've updated this PR so the new validate method receives a HCursor => List[String] function to represent both the predicate and the errors generated by falsifying it.

New changes in the last commit: ca44c79

@travisbrown
Copy link
Member

Thanks, looks good to me!

@travisbrown travisbrown merged commit 51820d5 into circe:master Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants