[`refined4s-chimney`] Add `PartialTransformer` to transform `Refined[A]` to `Newtype[Refined[A]]` for `ChimneyRefined`
Closed this issue · 0 comments
kevin-lee commented
Summary
[refined4s-chimney
] Add PartialTransformer
to transform Refined[A]
to Newtype[Refined[A]]
for ChimneyRefined
Version
0.17.0
Description
import refined4s.*
import refined4s.modules.chimney.derivation.*
import io.scalaland.chimney.*
import io.scalaland.chimney.dsl.*
final case class XMen(name: XMen.NotEmptyStr)
object XMen {
type NotEmptyStr = NotEmptyStr.Type
object NotEmptyStr extends Refined[String], ChimneyRefined[String] {
inline def invalidReason(a: String): String = "non-empty String"
inline def predicate(a: String): Boolean = a != ""
}
}
import refined4s.types.all.*
final case class MarvelCharacter(name: MarvelCharacter.Name)
object MarvelCharacter {
type Name = Name.Type
object Name extends Newtype[NonEmptyString], ChimneyNewtype[NonEmptyString]
}
val logan = XMen(XMen.NotEmptyStr("James Howlett"))
import refined4s.modules.chimney.derivation.types.all.*
val wolverine = logan.transformIntoPartial[MarvelCharacter]