Skip to content

Instantly share code, notes, and snippets.

@umbreak
Created March 1, 2018 18:17
Show Gist options
  • Save umbreak/b4c6e2b341f1a4974108d440827d7acb to your computer and use it in GitHub Desktop.
Save umbreak/b4c6e2b341f1a4974108d440827d7acb to your computer and use it in GitHub Desktop.
import ch.epfl.bluebrain.nexus.admin.ld.other.CustomRefinements.CustomType
import ch.epfl.bluebrain.nexus.admin.ld.other.ProjectRefinements.{ProjectReference, ProjectReferencePredicate}
import eu.timepit.refined._
import eu.timepit.refined.api._
import eu.timepit.refined.collection._
import eu.timepit.refined.auto._
import eu.timepit.refined.string.MatchesRegex
object Collect {
final case class Something(some: CustomType)
trait SomethingAble[A] extends (A => Something)
final implicit val inference: Inference[ProjectReferencePredicate, NonEmpty] =
Inference.alwaysValid("A Project Reference is always a valid Custom Type")
final implicit val projectReferenceToIdRef: SomethingAble[ProjectReference] = (a: ProjectReference) => {
Something(a)
}
}
object CustomRefinements {
type CustomType = String Refined NonEmpty
}
object ProjectRefinements {
type ProjectReferencePredicate = MatchesRegex[W.`"[a-zA-Z0-9-_]{3,16}"`.T]
type ProjectReference = String Refined ProjectReferencePredicate
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment