Last active
July 23, 2021 07:42
-
-
Save omerlh/504c0050736df8a600a67b5f56641c2d to your computer and use it in GitHub Desktop.
Refined Types
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
interface UserInput { | |
age: Number | |
} | |
var input = JSON.parse("{\"age\": \"hello\"}") as UserInput | |
console.log(typeof(input.age)) |
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.boolean._ | |
import eu.timepit.refined.string._ | |
object Types { | |
type userEmail = String Refined MatchesRegex[".*@gmail.com"] | |
type ipAddress = String Refined IPv4 Or IPv6 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment