-
Notifications
You must be signed in to change notification settings - Fork 144
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
Support error accumulation #771
Comments
Actually there is an equivalent: https://zio.github.io/zio-prelude/docs/functionaldatatypes/validation. |
validation could be the implementation but with the decoder that fail on first will not help the case |
This is only the default implementation to not force users to make an accumulative and non-accumulative implementation for their Decoder. AFAIK |
Accumulating error enables to get and return all occured errors during Json decoding:
This is especially useful for form-like/API validation. This can be compared to Circe's
decodeAccumulating
or Cats'Validated
.As far as I know, there's no
Validated
equivalent for ZIO/ZIO Prelude but anEither[List[String], A]
would be enough.For example, I would like my above example to return
Left(List(".name(...)", ".age(...)"))
.In Circe, this is achieved by defining a second method in the
Decoder
(in ZIO-JSON,JsonDecoder
) typeclass nameddecodeAccumulating
which could be nameddecodeJsonAccumulating
to feel more consistent with the existingdecodeJson
method.To preserve retrocompatibility and because sometimes it's non sense to use error accumulation, the method can be defined like this by default:
The text was updated successfully, but these errors were encountered: