You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract sealed class Location(val name: String)
object Location {
final case object AustraliaEast extends Location("australiaeast")
def fromString(name: String): Location = name match {
case AustraliaEast.name => AustraliaEast
}
}
I derive the ConfigParser for Location by specifying the DerivedConfigFieldParser for location.
implicit val locDerivedConfigFieldParser: DerivedConfigFieldParser[Location] =
implicitly[DerivedConfigFieldParser[String]].map(Location.fromString)
Is there already a better way of doing it?
If not, it would be more intuitive to define just a ConfigParser[Location] (using the ConfigParser[String]). Something along the below lines.
implicit val configParser: ConfigParser[Location] =
ConfigParser[String].map(Location.fromString)
Looking at the code, it feels we could bring this behavior.