package refined
- Alphabetic
- By Inheritance
- refined
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- final case class PartialRefinedPath[FAP]() extends Product with Serializable
Value Members
- 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
- Annotations
- @silent("deprecated")
- def refine[Predicate]: PartialRefined[Predicate]
refine[Predicate] allows to retrieve a
refinedtype given an existingConfigand a predicate Predicate.refine[Predicate] allows to retrieve a
refinedtype given an existingConfigand a predicate Predicate. Example of a Predicate isNonEmpty.Example:
final case class MyConfig(url: String, port: Int) val configs: Config[List[MyConfig]] = listOf("databases", deriveConfig[MyConfig]) val configDescriptor: Config[Refined[List[MyConfig], Size[Greater[W.`2`.T]]]] = refine[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] - def refine[A, P](path: String)(implicit desc: DeriveConfig[A], validate: Validate[A, P]): Config[Refined[A, P]]
refineallows us to retrieve arefinedtype from a given path.refineallows us to retrieve arefinedtype from a given path.Example:
import eu.timepit.refined.string._ val configDescriptor: Config[Refined[String, Uuid]] = refined[String, Uuid]("ID")
- Annotations
- @silent("deprecated")
- 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 theConfigof 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 aboutRefinedmodules, allowing you to then pass theConfig[RawConfig]torefine[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]