github zio/zio-config v1.0.0-RC30

latest releases: v4.0.2, v4.0.1, v4.0.0...
3 years ago

Changes

Fixed #444

With this release, zio-config-refined is now a super light weight module, allowing any users who are used to refined library to come in and use it along with zio-config with almost zero learning curve.

 import zio.config.ConfigDescriptor
 import zio.config.refined.refine

 import eu.timepit.refined._, api._, string._

 // A string config, such that it should be a Url
 val urlConfig: ConfigDescriptor[Refined[String, Url]] =
   refine[String, Url]("URL")

A much more interesting use-case is being able to get a refined type out of an existing ConfigDescriptor.
Take a look at the below example

 import zio.config._, ConfigDescriptor._
 import zio.config.refined.refine
 import zio.config.magnolia.DeriveConfigDescriptor.descriptor

 import eu.timepit.refined._, api._, numeric._, collection._

 case class MyConfig(url: String, port: Int)

 val configs: ConfigDescriptor[List[MyConfig]] =
   list("databases")(descriptor[MyConfig])

 // A list of database configs, such that size should be greater than 2.
 val databaseList: ConfigDescriptor[Refined[List[MyConfig], Size[Greater[W.`2`.T]]]] =
   refine[List[MyConfig], Size[Greater[W.`2`.T]]](configs)

Don't miss a new zio-config release

NewReleases is sending notifications on new releases.