OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned. If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages.
(ff ...DecodeHookFunc)
| 80 | // OrComposeDecodeHookFunc executes all input hook functions until one of them returns no error. In that case its value is returned. |
| 81 | // If all hooks return an error, OrComposeDecodeHookFunc returns an error concatenating all error messages. |
| 82 | func OrComposeDecodeHookFunc(ff ...DecodeHookFunc) DecodeHookFunc { |
| 83 | return func(a, b reflect.Value) (interface{}, error) { |
| 84 | var allErrs string |
| 85 | var out interface{} |
| 86 | var err error |
| 87 | |
| 88 | for _, f := range ff { |
| 89 | out, err = DecodeHookExec(f, a, b) |
| 90 | if err != nil { |
| 91 | allErrs += err.Error() + "\n" |
| 92 | continue |
| 93 | } |
| 94 | |
| 95 | return out, nil |
| 96 | } |
| 97 | |
| 98 | return nil, errors.New(allErrs) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // StringToSliceHookFunc returns a DecodeHookFunc that converts |
| 103 | // string to []string by splitting on the given sep. |
searching dependent graphs…