zio-schema icon indicating copy to clipboard operation
zio-schema copied to clipboard

Unable to convert to TypedValue

Open tusharmath opened this issue 1 year ago • 14 comments

If the schema is rebuilt from the AST, it doesn't correctly convert a dynamic value back to a typed value. This is specifically happening with records.

import zio.schema._


final case class User(name: String, age: Int)


implicit val schema = DeriveSchema.gen[User]


val user = User("John", 30)
val userDynamic = schema.toDynamic(user)


println(userDynamic)
println(userDynamic.toTypedValue(schema))
println(userDynamic.toTypedValue(schema.ast.toSchema))

https://scastie.scala-lang.org/TJmOjesrS5KY5ZYHOwJTUg

tusharmath avatar Feb 10 '23 06:02 tusharmath