Skip to content

Should contains find partial path matches? #77

@ppslim

Description

@ppslim

Sample Properties file

prefix1.prefixA.name.keyA.key1 = value
prefix1.prefixA.name.keyA.key2 = value
prefix1.prefixA.name.keyB.key1 = value
prefix1.prefixA.name.keyB.key2 = value
prefix1.prefixB.name.keyA.key1 = value
prefix1.prefixB.name.keyA.key2 = value
prefix1.prefixB.name.keyB.key1 = value
prefix1.prefixB.name.keyB.key2 = value

If I use this such as via

val conf = Config().from.properties.resource("config/application.defaults.properties")

Should I be able to test if a given sub-path exists?

conf.contains("prefix1.prefixB.name")

As of right now, this always returns false for me.

Per the Properties, children of the Path exist. I use the Spec as follows and successfully so, despite the contains returning false

object SomeSpec: ConfigSpec("") {
  val keyA1 by optional("NOT_SET", "keyA.key1")
  val keyA2 by optional("NOT_SET", "keyA.key1")
  val keyB1 by optional("NOT_SET", "keyB.key2")
  val keyB2 by optional("NOT_SET", "keyB.key2")
}

val prefixb = conf.withLayer("child.prefixB").also {
  it.addSpec(SomeSpec.withPrefix("prefix1.prefixB.name"))
}

println("keyB2: ${prefixb[SomeSpex.keyB2]}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions