Add option to disallow unknown fields
This commit is contained in:
@ -33,7 +33,8 @@ type DecoderReader = interface {
|
||||
io.Reader
|
||||
}
|
||||
type Decoder struct {
|
||||
r DecoderReader
|
||||
r DecoderReader
|
||||
disallowUnknownFields bool
|
||||
}
|
||||
|
||||
func NewDecoder(r io.Reader) *Decoder {
|
||||
@ -46,6 +47,12 @@ func NewDecoder(r io.Reader) *Decoder {
|
||||
return d
|
||||
}
|
||||
|
||||
// DisallowUnknownFields makes the decoder return an error when unmarshalling a compound
|
||||
// tag item that has a tag name not present in the destination struct.
|
||||
func (d *Decoder) DisallowUnknownFields() {
|
||||
d.disallowUnknownFields = true
|
||||
}
|
||||
|
||||
type reader struct {
|
||||
io.Reader
|
||||
}
|
||||
|
Reference in New Issue
Block a user