Packages

p

zio.config

refined

package refined

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. refined
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class PartialRefinedPath[FAP]() extends Product with Serializable

Value Members

  1. implicit def deriveRefinedDescriptor[A, P](implicit desc: Descriptor[A], validate: Validate[A, P]): Descriptor[Refined[A, P]]

    FIXME Automatically derive instances of Descriptor for any refined types

    FIXME Automatically derive instances of Descriptor for any refined types

    Annotations
    @silent("deprecated")
  2. def refine[Predicate]: PartialRefined[Predicate]

    refine[Predicate] allows to retrieve a refined type given an existing ConfigDescriptor and a predicate Predicate.

    refine[Predicate] allows to retrieve a refined type given an existing ConfigDescriptor and a predicate Predicate. Example of a Predicate is NonEmpty.

    Example:

    import zio.config.magnolia.descriptor
    
    final case class MyConfig(url: String, port: Int)
    
    val configs: ConfigDescriptor[List[MyConfig]] =
      list("databases")(descriptor[MyConfig])
    
    val configDescriptor: ConfigDescriptor[Refined[List[MyConfig], Size[Greater[W.`2`.T]]]] =
      refined[Size[Greater[W.`2`.T]]](configs)

    If you don't care predicates specifically, and need to pass a fully formed Refined type (Example: type NonEmptyString = String Refined NonEmpty), refer refineType[RefinedType]

  3. def refine[A, P](path: String)(implicit desc: Descriptor[A], validate: Validate[A, P]): config.ConfigDescriptor[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: ConfigDescriptor[Refined[String, Uuid]] =
      refined[String, Uuid]("ID")
    Annotations
    @silent("deprecated")
  4. def refineType[R]: PartialRefinedPath[R]

    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 ConfigDescriptor of the underlying type.

    Example:

    type NonEmptyString = String Refined NonEmpty
    refineType[NonEmptyString]("USERNAME")
    
    // is same as
    
    val userName: ConfigDescriptor[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 ConfigDescriptor without worrying about Refined modules, allowing you to then pass the ConfigDescriptor[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: ConfigDescriptor[Jdbc] =
      (refineType[NonEmptyString]("username") zip refineType[NonEmptyString]("password")).to[Jdbc]

Inherited from AnyRef

Inherited from Any

Ungrouped