MCPcopy
hub / github.com/pocketbase/pocketbase / JoinValidationErrors

Function JoinValidationErrors

core/validators/validators.go:18–40  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

16//
17// If both arguments are not [validation.Errors] then it returns a combined [errors.Join] error.
18func 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
42func cutStr(str string, max int) string {
43 if len(str) > max {

Callers 2

runMethod · 0.92
TestJoinValidationErrorsFunction · 0.92

Calls 2

CopyMethod · 0.65
CloneMethod · 0.45

Tested by 1

TestJoinValidationErrorsFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…