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

Refined interop should include additional Validate instances #975

Open
gnp opened this issue Jul 2, 2023 · 0 comments
Open

Refined interop should include additional Validate instances #975

gnp opened this issue Jul 2, 2023 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@gnp
Copy link

gnp commented Jul 2, 2023

It is not possible to do this with zio-json-interop-refined:JsonDecoder[ast.Json.Obj Refined Empty]. This is because the Empty validation requires the target to implement Iterable, and ast.Json.Obj does not. There may be other cases for the types under ast.Json.* where a natural validation doesn't work.

For the specific case above, I had to add this to my code to get it to work:

  import eu.timepit.refined.api.Validate
  implicit def emptyObjValidate: Validate.Plain[ast.Json.Obj, Empty] =
    Validate
      .fromPredicate[ast.Json.Obj, Empty](t => t.isEmpty, t => s"isEmpty(keys: ${t.keys.mkString(", ")})", Empty())
@fsvehla fsvehla added the help wanted Extra attention is needed label Jul 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants