MCPcopy
hub / github.com/crowdsecurity/crowdsec / validateMetrics

Method validateMetrics

pkg/models/base_metrics.go:68–92  ·  view source on GitHub ↗
(formats strfmt.Registry)

Source from the content-addressed store, hash-verified

66}
67
68func (m *BaseMetrics) validateMetrics(formats strfmt.Registry) error {
69 if swag.IsZero(m.Metrics) { // not required
70 return nil
71 }
72
73 for i := 0; i < len(m.Metrics); i++ {
74 if swag.IsZero(m.Metrics[i]) { // not required
75 continue
76 }
77
78 if m.Metrics[i] != nil {
79 if err := m.Metrics[i].Validate(formats); err != nil {
80 if ve, ok := err.(*errors.Validation); ok {
81 return ve.ValidateName("metrics" + "." + strconv.Itoa(i))
82 } else if ce, ok := err.(*errors.CompositeError); ok {
83 return ce.ValidateName("metrics" + "." + strconv.Itoa(i))
84 }
85 return err
86 }
87 }
88
89 }
90
91 return nil
92}
93
94func (m *BaseMetrics) validateOs(formats strfmt.Registry) error {
95 if swag.IsZero(m.Os) { // not required

Callers 1

ValidateMethod · 0.95

Calls 2

IsZeroMethod · 0.80
ValidateMethod · 0.65

Tested by

no test coverage detected