Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

feature: assertion of exhaustive mapping for ArbitraryTypeReader #13

Open
frohoff opened this issue May 7, 2015 · 0 comments
Open

feature: assertion of exhaustive mapping for ArbitraryTypeReader #13

frohoff opened this issue May 7, 2015 · 0 comments

Comments

@frohoff
Copy link

frohoff commented May 7, 2015

I would be helpful if ArbitraryTypeReader offered a mode/setting that adds a runtime check that all keys for a Config object were mapped into the instantiation parameters successfully and that no keys were left un-mapped after instantiation. Current behavior silently ignores Config keys that don't match a parameter when that parameter is optional (Option or default value), allowing simple typo bugs that could be caught at instantiation time to slip into runtime.

Example:

case class Test(foo: String = "foo", bar: Option[String])

val cfg = ConfigFactory.parseString("""
    test {
        fooTypo: overrideFoo
        barTypo: overrideBar
    }
    """)                                            

val test = cfg.as[Test]("test")  
//> test  : worksheet.Test = Test(foo,None)
// note default values are not overridden
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant