Skip to content

Instantly share code, notes, and snippets.

@animatedlew
Last active September 12, 2017 01:23
Show Gist options
  • Select an option

  • Save animatedlew/5bbf4e460afe284e56c3bc1d2580e328 to your computer and use it in GitHub Desktop.

Select an option

Save animatedlew/5bbf4e460afe284e56c3bc1d2580e328 to your computer and use it in GitHub Desktop.
import eu.timepit.refined._
import eu.timepit.refined.string._
import eu.timepit.refined.api._
import io.circe.generic.auto._
import io.circe.parser._
import io.circe.syntax._
import io.circe.refined._
import Log._
case class Log(auth: Auth0, version: Version)
object Log {
val auth0 = W("auth0")
val version = W("v([1-9]+)(\\.(\\d+)(\\.(\\d+))?)?")
type Version = String Refined MatchesRegex[version.T]
type Auth0 = String Refined StartsWith[auth0.T]
}
decode[Log]("""{"auth": "auth0","version": "v1.23.2"}""").map(_.asJson.noSpaces)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment