sksamuel / hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes
Apache License 2.0
923 stars 74 forks source link

YAML validation of string values for list-of-string types #394

Open luther7 opened 1 year ago

luther7 commented 1 year ago

Hi! Thanks for the free software. 🙏

For YAML, string values for list-of-string types are valid. They are deserialized into a list, splitting the string by commas. Example:

data class TestConfig(val testList: List<String>)
val testSource = "testList: Hello, world!"

ConfigLoaderBuilder
.default()
.addSource(YamlPropertySource(testSource))
.build()
.loadConfig<TestConfig>()
.map {
  println(it)
  // TestConfig(testList=[Hello, world!])
  println(it.testList.size)
  // 2
}

Thanks!

sksamuel commented 1 year ago

Is there a question here :)