Add decoder opts to unmarshal exact

This commit is contained in:
Mark Sagi-Kazar 2019-12-06 14:23:11 +01:00 committed by Márk Sági-Kazár
parent bcb420b705
commit 5ad4bc05cf

View file

@ -949,9 +949,11 @@ func decode(input interface{}, config *mapstructure.DecoderConfig) error {
// UnmarshalExact unmarshals the config into a Struct, erroring if a field is nonexistent
// in the destination struct.
func UnmarshalExact(rawVal interface{}) error { return v.UnmarshalExact(rawVal) }
func (v *Viper) UnmarshalExact(rawVal interface{}) error {
config := defaultDecoderConfig(rawVal)
func UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error {
return v.UnmarshalExact(rawVal, opts...)
}
func (v *Viper) UnmarshalExact(rawVal interface{}, opts ...DecoderConfigOption) error {
config := defaultDecoderConfig(rawVal, opts...)
config.ErrorUnused = true
err := decode(v.AllSettings(), config)