forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
45 lines (38 loc) · 777 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package schema
type Errors []Error
func NewErrors() *Errors {
return &Errors{}
}
func (errs *Errors) AddError(err *Error) {
*errs = append(*errs, *err)
}
func (errs *Errors) AddErrors(errors *Errors) {
if errors == nil {
return
}
*errs = append(*errs, *errors...)
}
func (errs *Errors) HasRequiredErrors() bool {
for _, err := range *errs {
if err.IsType(RequiredType) {
return true
}
}
return false
}
func (errs *Errors) Error() string {
error := "Required fields are missing: "
for _, err := range *errs {
if err.IsType(RequiredType) {
error = error + "," + err.key
}
}
return error
}
func (errs *Errors) ErrorDebug() string {
error := "Fields are missing: "
for _, err := range *errs {
error = error + "," + err.key
}
return error
}