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

Method UnmarshalJSON

model/silence.go:30–45  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

28}
29
30func (m *Matcher) UnmarshalJSON(b []byte) error {
31 type plain Matcher
32 if err := json.Unmarshal(b, (*plain)(m)); err != nil {
33 return err
34 }
35
36 if len(m.Name) == 0 {
37 return fmt.Errorf("label name in matcher must not be empty")
38 }
39 if m.IsRegex {
40 if _, err := regexp.Compile(m.Value); err != nil {
41 return err
42 }
43 }
44 return nil
45}
46
47// Validate returns true iff all fields of the matcher have valid values.
48func (m *Matcher) Validate() error {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected