← ZIO Config docs

zio.config.refined

Members list

Type members

Classlikes

final case class PartialRefinedPath[FAP]()

Attributes

Source
PartialRefinedPath.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def refine[A, P](path: String)(implicit desc: DeriveConfig[A], validate: Validate[A, P]): Config[Refined[A, P]]

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

implicit def deriveRefinedDescriptor[A, P](implicit desc: DeriveConfig[A], validate: Validate[A, P]): DeriveConfig[Refined[A, P]]

FIXME Automatically derive instances of Descriptor for any refined types

FIXME Automatically derive instances of Descriptor for any refined types

Attributes

Source
package.scala