From 18ba04ac2164e08f4db74d0d2e7d8e0c541a890a Mon Sep 17 00:00:00 2001 From: Matthias Berndt Date: Thu, 5 Sep 2024 13:38:44 +0200 Subject: [PATCH] add DeriveConfig instances for NonEmptyChunk --- .../scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala | 5 ++++- .../main/scala-dotty/zio/config/magnolia/DeriveConfig.scala | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala b/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala index 6e7c63915..6c35914f6 100644 --- a/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala +++ b/magnolia/shared/src/main/scala-2.12-2.13/zio/config/magnolia/DeriveConfig.scala @@ -2,7 +2,7 @@ package zio.config.magnolia import magnolia._ import zio.config._ -import zio.{Chunk, Config, LogLevel} +import zio.{Chunk, NonEmptyChunk, Config, LogLevel} import java.net.URI import java.time.{LocalDate, LocalDateTime, LocalTime, OffsetDateTime} @@ -75,6 +75,9 @@ object DeriveConfig { implicit def implicitChunkDesc[A: DeriveConfig]: DeriveConfig[Chunk[A]] = DeriveConfig(Config.chunkOf(DeriveConfig[A].desc)) + implicit def implicitNonEmptyChunkDesc[A: DeriveConfig]: DeriveConfig[NonEmptyChunk[A]] = + DeriveConfig(Config.nonEmptyChunkOf(DeriveConfig[A].desc)) + implicit def implicitMapDesc[A: DeriveConfig]: DeriveConfig[Map[String, A]] = DeriveConfig(Config.table(implicitly[DeriveConfig[A]].desc)) diff --git a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala index d54a467ac..498c4879a 100644 --- a/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala +++ b/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/DeriveConfig.scala @@ -107,6 +107,9 @@ object DeriveConfig { given chunkDesc[A](using ev: DeriveConfig[A]): DeriveConfig[Chunk[A]] = DeriveConfig.from(chunkOf(ev.desc)) + given nonEmptyChunkDesc[A](using ev: DeriveConfig[A]): DeriveConfig[NonEmptyChunk[A]] = + DeriveConfig.from(nonEmptyChunkOf(ev.desc)) + given mapDesc[A](using ev: DeriveConfig[A]): DeriveConfig[Map[String, A]] = DeriveConfig.from(table(ev.desc))