Skip to content

Commit

Permalink
Add decoder opts to unmarshal exact
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Dec 6, 2019
1 parent bcb420b commit 5ad4bc0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions viper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5ad4bc0

Please sign in to comment.