mirror of
https://github.com/caddyserver/caddy.git
synced 2026-08-27 04:07:28 +00:00
cmd: Strict unmarshal for validate (#5383)
This commit is contained in:
parent
8bc05e598d
commit
79de6df93d
4 changed files with 6 additions and 6 deletions
|
|
@ -333,11 +333,11 @@ func ParseStructTag(tag string) (map[string]string, error) {
|
|||
return results, nil
|
||||
}
|
||||
|
||||
// strictUnmarshalJSON is like json.Unmarshal but returns an error
|
||||
// StrictUnmarshalJSON is like json.Unmarshal but returns an error
|
||||
// if any of the fields are unrecognized. Useful when decoding
|
||||
// module configurations, where you want to be more sure they're
|
||||
// correct.
|
||||
func strictUnmarshalJSON(data []byte, v any) error {
|
||||
func StrictUnmarshalJSON(data []byte, v any) error {
|
||||
dec := json.NewDecoder(bytes.NewReader(data))
|
||||
dec.DisallowUnknownFields()
|
||||
return dec.Decode(v)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue