ficus icon indicating copy to clipboard operation
ficus copied to clipboard

feature: assertion of exhaustive mapping for ArbitraryTypeReader

Open frohoff opened this issue 10 years ago • 0 comments

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

frohoff avatar May 07 '15 16:05 frohoff