...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package models
18
19
20
21
22 import (
23 "context"
24 "strconv"
25
26 "github.com/go-openapi/errors"
27 "github.com/go-openapi/strfmt"
28 "github.com/go-openapi/swag"
29 )
30
31
32
33
34 type GettableAlerts []*GettableAlert
35
36
37 func (m GettableAlerts) Validate(formats strfmt.Registry) error {
38 var res []error
39
40 for i := 0; i < len(m); i++ {
41 if swag.IsZero(m[i]) {
42 continue
43 }
44
45 if m[i] != nil {
46 if err := m[i].Validate(formats); err != nil {
47 if ve, ok := err.(*errors.Validation); ok {
48 return ve.ValidateName(strconv.Itoa(i))
49 } else if ce, ok := err.(*errors.CompositeError); ok {
50 return ce.ValidateName(strconv.Itoa(i))
51 }
52 return err
53 }
54 }
55
56 }
57
58 if len(res) > 0 {
59 return errors.CompositeValidationError(res...)
60 }
61 return nil
62 }
63
64
65 func (m GettableAlerts) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
66 var res []error
67
68 for i := 0; i < len(m); i++ {
69
70 if m[i] != nil {
71 if err := m[i].ContextValidate(ctx, formats); err != nil {
72 if ve, ok := err.(*errors.Validation); ok {
73 return ve.ValidateName(strconv.Itoa(i))
74 } else if ce, ok := err.(*errors.CompositeError); ok {
75 return ce.ValidateName(strconv.Itoa(i))
76 }
77 return err
78 }
79 }
80
81 }
82
83 if len(res) > 0 {
84 return errors.CompositeValidationError(res...)
85 }
86 return nil
87 }
88
View as plain text