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

Compose field validation #9

Closed
MateuszKubuszok opened this issue Feb 11, 2018 · 2 comments
Closed

Compose field validation #9

MateuszKubuszok opened this issue Feb 11, 2018 · 2 comments

Comments

@MateuszKubuszok
Copy link
Contributor

Given:

case class A(...)
case class A2(...)
case class B(a: A, a2: A2)

val av: Validator[A] = ...
val bv: Validator[B] = ...

right now, we are only able to use av inside bv if we make av implicit and use it during derivation. If we wanted to enhance some existing av, e.g. created with comap, we would have to do something like:

implicit val av: Validator[A] = ...

implicit val a2v: Validator[A2] = Validator[A2] // empty validator just for the sake of derivation

val bv: Validator[B] = ...

bv.composeDerived

which can generate some boilerplate at a times (the bigger B gets the more we will notice that). Given that there is already existing syntax for validating fields it would be intuitive to provide something like:

bv.rule(_.a, av)
@krzemin
Copy link
Owner

krzemin commented Mar 20, 2018

I guess compose or composeSuper may help you in such case.

Look also at this example: #10 (comment)

@krzemin
Copy link
Owner

krzemin commented Apr 11, 2020

Closing due to inactivity.

@krzemin krzemin closed this as completed Apr 11, 2020
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

No branches or pull requests

2 participants