zio.config.refined
Members list
Type members
Classlikes
Attributes
- Source
- PartialRefinedPath.scala
- Supertypes
Value members
Concrete methods
refine allows us to retrieve a refined type from a given path.
refine allows us to retrieve a refined type from a given path.
Example:
import eu.timepit.refined.string._
val configDescriptor: Config[Refined[String, Uuid]] =
refined[String, Uuid]("ID")
Attributes
- Source
- package.scala
refineType[RefinedType] allows to retrieve a RefinedType (example: NonEmptyString) from a path.
refineType[RefinedType] allows to retrieve a RefinedType (example: NonEmptyString) from a path.
Unlike refine[Predicate] method, refineType[RefinedType] allows you to a pass a fully formed refined type and be careless about the Config of the underlying type.
Example:
type NonEmptyString = String Refined NonEmpty
refineType[NonEmptyString]("USERNAME")
// is same as
val userName: Config[String] = string("USERNAME")
refine[NonEmpty](userName)
While, refineType[RefinedType] is useful for simple application, refine[Predicate] can be more flexible in complex configurations where you need more orthogonality between raw config and refined configs.
refine[Predicate] allows you to build entire Config without worrying about Refined modules, allowing you to then pass the Config[RawConfig] to refine[Predicate] and refine the types, which is more into an orthogonal design.
A complete example of refineType:
import zio.config._
import eu.timepit.refined.types.string.NonEmptyString
final case class Jdbc(username: NonEmptyString, password: NonEmptyString)
val jdbc: Config[Jdbc] =
(refineType[NonEmptyString]("username") zip refineType[NonEmptyString]("password")).to[Jdbc]
Attributes
- Source
- package.scala
Implicits
Implicits
FIXME Automatically derive instances of Descriptor for any refined types
FIXME Automatically derive instances of Descriptor for any refined types
Attributes
- Source
- package.scala