Error Path Support #58
Replies: 1 comment 1 reply
-
Omitting error-path support was a conscious decision I made when designing I actually have an implementation of this ready to go here which then gets passed in here. An example usage would look like this: final case class Person(name: Person.Name, age: Person.Age)
object Person {
object Name extends NewtypeValidated[String, NonEmpty]
export Name.Type as Name
object Age extends NewtypeValidated[String, GreaterThan[0]]
export Age.Name as Age
} And then when something fails in your fallible transformation you'd get an error message like As for keys and indices, that can also be achieved by creating a new implementation of either Of course you do not get the exact path of failure that way, but IMO it's enough. I'm also not completely opposed to the idea of baking in error path support but it'd be pretty low on my priority list right now :) |
Beta Was this translation helpful? Give feedback.
-
It would be great if Ducktape will support error paths like Chimney.
There are many ways to implement it, but I think adding a function such as
def nestPath(fa: F[A], path: String): F[A]
intotrait Transformer.Mode
seems like a good choice. It's for being called with the field names, list indice or coproduct cases reflected from the macro code.A default implementation such as
def nestPath(fa: F[A], path: String): F[A] = fa
can be provided to avoid any breaking changes.Beta Was this translation helpful? Give feedback.
All reactions