You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When decoding a case class from a Json AST, if there are errors for any of the properties the error message does not contain the failing property names.
See example below.
scala> case class Test(a: NonEmptyString, b: String, c: Int)
class Test
scala> import zio.json.compat.refined._
import zio.json._
import eu.timepit.refined.types.all._
import zio.json.compat.refined._
import zio.json._
import eu.timepit.refined.types.all._
scala> implicit val dec: JsonDecoder[Test] = DeriveJsonDecoder.gen
val dec: zio.json.JsonDecoder[Test] = zio.json.DeriveJsonDecoder$$anon$2@7d8a9b95
//From String to A, rightly signalled that the error is in the property "a"
scala> """{"a": "", "b": "", "c": 1}""".fromJson[Test]
val res2: Either[String,Test] = Left(.a(Predicate isEmpty() did not fail.))
//From String to Json.Obj
scala> """{"a": "", "b": "", "c": 1}""".fromJson[ast.Json.Obj]
val res3: Either[String,zio.json.ast.Json.Obj] = Right({"a":"","b":"","c":1})
//From Json.Obj to A, missing the property name "a" in the error message
scala> res3.flatMap(_.as[Test])
val res5: scala.util.Either[String,Test] = Left(Predicate isEmpty() did not fail.)
The text was updated successfully, but these errors were encountered:
When decoding a case class from a Json AST, if there are errors for any of the properties the error message does not contain the failing property names.
See example below.
The text was updated successfully, but these errors were encountered: