MCPcopy Create free account
hub / github.com/prometheus/common / Validate

Method Validate

model/silence.go:49–61  ·  view source on GitHub ↗

Validate returns true iff all fields of the matcher have valid values.

()

Source from the content-addressed store, hash-verified

47
48// Validate returns true iff all fields of the matcher have valid values.
49func (m *Matcher) Validate() error {
50 if !m.Name.IsValid() {
51 return fmt.Errorf("invalid name %q", m.Name)
52 }
53 if m.IsRegex {
54 if _, err := regexp.Compile(m.Value); err != nil {
55 return fmt.Errorf("invalid regular expression %q", m.Value)
56 }
57 } else if !LabelValue(m.Value).IsValid() || len(m.Value) == 0 {
58 return fmt.Errorf("invalid value %q", m.Value)
59 }
60 return nil
61}
62
63// Silence defines the representation of a silence definition in the Prometheus
64// eco-system.

Callers 1

ValidateMethod · 0.45

Calls 2

LabelValueTypeAlias · 0.85
IsValidMethod · 0.45

Tested by

no test coverage detected