Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should contains find partial path matches? #77

Open
ppslim opened this issue May 30, 2022 · 1 comment
Open

Should contains find partial path matches? #77

ppslim opened this issue May 30, 2022 · 1 comment
Labels

Comments

@ppslim
Copy link

ppslim commented May 30, 2022

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]}")
@stale
Copy link

stale bot commented May 24, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the stale label May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant