Created
November 23, 2019 11:14
-
-
Save kellydavid/4b8ba0a8867629212b4e6cbaa2a0c642 to your computer and use it in GitHub Desktop.
Refined Types Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.string.{Url, Uuid} | |
import eu.timepit.refined.auto._ | |
case class MyId(value: String Refined Uuid) | |
val invalidUrl: String Refined Url = "htp://example.com" | |
val validUuid: String Refined Uuid = "61f33e31-5ef6-4aac-b7e2-c8374c19c366" | |
val validProductId = MyId(validUuid) | |
val invalidUuid: String Refined Uuid = "19edb10f-4a5c-4e42-966c-invalid" | |
val invalidProductId = MyId(invalidUuid) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment