diff options
author | Zach Smith <zach@driver.xyz> | 2018-07-19 15:57:53 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-19 15:57:53 +0800 |
commit | 819c8d14ed32785995ba8a42bdac80a8d9f2c557 (patch) | |
tree | 616d3b012d8c74c39772d87f93a912bcacbd621e /src/test/scala/xyz/driver/core | |
parent | 31cbc4b16751c9ed900ce04d932213b3f0dc961e (diff) | |
download | driver-core-1.11.8.tar.gz driver-core-1.11.8.tar.bz2 driver-core-1.11.8.zip |
Validate phone numbers when parsing from JSON (#183)v1.11.8
* Validate phone numbers when parsing from JSON
* Change to intercept for test
Diffstat (limited to 'src/test/scala/xyz/driver/core')
-rw-r--r-- | src/test/scala/xyz/driver/core/JsonTest.scala | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/JsonTest.scala b/src/test/scala/xyz/driver/core/JsonTest.scala index fed2a9d..2c85560 100644 --- a/src/test/scala/xyz/driver/core/JsonTest.scala +++ b/src/test/scala/xyz/driver/core/JsonTest.scala @@ -135,6 +135,14 @@ class JsonTest extends FlatSpec with Matchers { parsedPhoneNumber should be(referencePhoneNumber) } + it should "reject an invalid phone number" in { + val phoneJson = """{"countryCode":"1","number":"111-111-1113"}""".parseJson + + intercept[DeserializationException] { + json.phoneNumberFormat.read(phoneJson) + }.getMessage shouldBe "Invalid phone number" + } + "Json format for ADT mappings" should "read and write correct JSON" in { sealed trait EnumVal |