Skip to content

Instantly share code, notes, and snippets.

@afsalthaj
Last active April 11, 2018 07:28
Show Gist options
  • Save afsalthaj/b07c2bbe1279e49d5c7085c4571164cd to your computer and use it in GitHub Desktop.
Save afsalthaj/b07c2bbe1279e49d5c7085c4571164cd to your computer and use it in GitHub Desktop.
implicit def genericValidation[A, R](
implicit gen: Generic.Aux[A, R], env: Validation[R]
): Validation[A] =
new Validation[A] {
override def validate(b: A) =
env.validate(gen.to(b)).map(gen.from)
}
// Please note that Generic.Aux[A, R] === Generic[A] {type Repr = R}
// as we cannot do env: Validation[gen.Repr]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment