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

Ensure json errors accumulate for custom decoders #373

Merged
merged 3 commits into from
Jul 29, 2021

Conversation

jisantuc
Copy link
Contributor

@jisantuc jisantuc commented Jul 29, 2021

Overview

This PR defines apply in terms of decodeAccumulating to ensure the behavior of decodeAccumulating is correct. Previously decodeAccumulating relied on the default implementation for a codec with an apply defined, which takes the Result (an Either) and wraps the error in a ValidatedNel if present: https://github.com/circe/circe/blob/master/modules/core/shared/src/main/scala/io/circe/Decoder.scala#L50-L60. Here instead we flip it.

We didn't accumulate errors previously despite using mapN because c.get returns an Either, and Either's applicative doesn't accumulate 🕵🏻‍♂️

Checklist

  • New tests have been added or existing tests have been modified
  • Changelog updated (please use chan)

Closes #372

@jisantuc jisantuc merged commit 947c13b into master Jul 29, 2021
@jisantuc jisantuc deleted the bugfix/js/ensure-json-errors-accumulate branch July 29, 2021 21:05
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.

Decoders (at least some of them) don't accumulate errors
1 participant