github.com/crowdsecurity/crowdsec@v1.6.1/pkg/models/get_alerts_response.go (about) 1 // Code generated by go-swagger; DO NOT EDIT. 2 3 package models 4 5 // This file was generated by the swagger tool. 6 // Editing this file might prove futile when you re-run the swagger generate command 7 8 import ( 9 "context" 10 "strconv" 11 12 "github.com/go-openapi/errors" 13 "github.com/go-openapi/strfmt" 14 "github.com/go-openapi/swag" 15 ) 16 17 // GetAlertsResponse AlertsResponse 18 // 19 // swagger:model GetAlertsResponse 20 type GetAlertsResponse []*Alert 21 22 // Validate validates this get alerts response 23 func (m GetAlertsResponse) Validate(formats strfmt.Registry) error { 24 var res []error 25 26 for i := 0; i < len(m); i++ { 27 if swag.IsZero(m[i]) { // not required 28 continue 29 } 30 31 if m[i] != nil { 32 if err := m[i].Validate(formats); err != nil { 33 if ve, ok := err.(*errors.Validation); ok { 34 return ve.ValidateName(strconv.Itoa(i)) 35 } else if ce, ok := err.(*errors.CompositeError); ok { 36 return ce.ValidateName(strconv.Itoa(i)) 37 } 38 return err 39 } 40 } 41 42 } 43 44 if len(res) > 0 { 45 return errors.CompositeValidationError(res...) 46 } 47 return nil 48 } 49 50 // ContextValidate validate this get alerts response based on the context it is used 51 func (m GetAlertsResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 52 var res []error 53 54 for i := 0; i < len(m); i++ { 55 56 if m[i] != nil { 57 58 if swag.IsZero(m[i]) { // not required 59 return nil 60 } 61 62 if err := m[i].ContextValidate(ctx, formats); err != nil { 63 if ve, ok := err.(*errors.Validation); ok { 64 return ve.ValidateName(strconv.Itoa(i)) 65 } else if ce, ok := err.(*errors.CompositeError); ok { 66 return ce.ValidateName(strconv.Itoa(i)) 67 } 68 return err 69 } 70 } 71 72 } 73 74 if len(res) > 0 { 75 return errors.CompositeValidationError(res...) 76 } 77 return nil 78 }