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

Replace ValidationRule with Cat's Validated #513

Closed
vkostyukov opened this issue Jan 29, 2016 · 6 comments
Closed

Replace ValidationRule with Cat's Validated #513

vkostyukov opened this issue Jan 29, 2016 · 6 comments

Comments

@vkostyukov
Copy link
Collaborator

I don't have a particular solution in mind, but I think it's worth to have an opened ticket for this before we forget. I eagerly want to replace Finch's data types with the ones community share and understand. ValidationRule is a good candidate to be reaplced (in some way) with Cat's Validated.

@vkostyukov vkostyukov added this to the Finch 1.0.0 milestone Jan 29, 2016
@ilya-murzinov
Copy link
Contributor

@vkostyukov can you please clarify how exactly do you see this possible?
I don't get it, because finch's ValidationRule is just a some kind of convenient DSL for combining boolean predicates, but cats' Validated is a data type which encodes validation result.

@vkostyukov
Copy link
Collaborator Author

I think what we should aim for is to have default endpoints (i.e., param, header) returning Endpoint[ValidatedNel[Error, A]] instead of Endpoint[A]. A very similar (yet simpler) approach is described in this gist.

@sergeykolbasov
Copy link
Collaborator

What about the composition of endpoints?
Let's say I have:

get(param("foo") :: header("bar")) { (foo: A?, bar: B?) => {
    ...
  }
}

What is a type of A? and B? here?

@prayagupa
Copy link
Contributor

prayagupa commented Oct 15, 2018

I liked Finch: A Life Without Exceptions. I was thinking the same when I was first looking for REST libraries in scala, but none of them do that.

Then what I could not figure out is provide a way to encode response along with the http codes.

If we define an http endpoint is of type Either[Error, a], a is 2xx but what is going to be Error http code? And we might at least need types for "2xx, 4xx and 5xx". Maybe there is a way I could not think of.

@sergeykolbasov
Copy link
Collaborator

sergeykolbasov commented Oct 15, 2018

@prayagupd Yes, status should be a part of an error.

In our project services always return F[Either[Error, A]] where Error <: Throwable is a type that guarantees status, description etc. And then we just fold it into Output using Output.payload or Output.failure

@joroKr21
Copy link
Collaborator

Validation removed in #1471

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants