JoinValidationErrors attempts to join the provided [validation.Errors] arguments. If only one of the arguments is [validation.Errors], it returns the first non-empty [validation.Errors]. If both arguments are not [validation.Errors] then it returns a combined [errors.Join] error.
(errA, errB error)
| 16 | // |
| 17 | // If both arguments are not [validation.Errors] then it returns a combined [errors.Join] error. |
| 18 | func JoinValidationErrors(errA, errB error) error { |
| 19 | vErrA, okA := errA.(validation.Errors) |
| 20 | vErrB, okB := errB.(validation.Errors) |
| 21 | |
| 22 | // merge |
| 23 | if okA && okB { |
| 24 | result := maps.Clone(vErrA) |
| 25 | maps.Copy(result, vErrB) |
| 26 | if len(result) > 0 { |
| 27 | return result |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | if okA && len(vErrA) > 0 { |
| 32 | return vErrA |
| 33 | } |
| 34 | |
| 35 | if okB && len(vErrB) > 0 { |
| 36 | return vErrB |
| 37 | } |
| 38 | |
| 39 | return errors.Join(errA, errB) |
| 40 | } |
| 41 | |
| 42 | func cutStr(str string, max int) string { |
| 43 | if len(str) > max { |
searching dependent graphs…