(b []byte)
| 28 | } |
| 29 | |
| 30 | func (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. |
| 48 | func (m *Matcher) Validate() error { |
nothing calls this directly
no outgoing calls
no test coverage detected