Skip to content

Commit

Permalink
Wrong type/missing value tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pondzix committed Mar 26, 2024
1 parent ce3ff79 commit ed9151e
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class CasterSpec extends org.specs2.Specification { def is = s2"""
cast transforms decimal values with correct scale and precision $e14
cast does not transform decimal values with invalid scale or precision $e15
cast select any valid match when there are multiple accessors $e16
cast transforms required array values $e17
cast transforms required array values - null $e17
cast transforms required array values - no value $e18
"""

import ExampleFieldValue._
Expand Down Expand Up @@ -293,4 +294,12 @@ class CasterSpec extends org.specs2.Specification { def is = s2"""
val expected = NonEmptyList.one(WrongType(Json.Null, Type.String))
Caster.cast(caster, Field("top", fieldType, Nullable), inputJson) must beInvalid(expected)
}

def e18 = {
val inputJson = json"""[{}]"""
val fieldType = Type.Array(Type.Struct(List(Field("id", Type.String, Required, Set("id")))), Required)

val expected = NonEmptyList.one(WrongType(Json.Null, Type.String))
Caster.cast(caster, Field("top", fieldType, Nullable), inputJson) must beInvalid(expected)
}
}

0 comments on commit ed9151e

Please sign in to comment.