type Exact string
type Contains string
type Regexp string
+type Any struct{}
+type Never struct{}
func (s Prefix) Match(input string) bool {
return strings.HasPrefix(input, string(s))
return fmt.Sprintf("%T(%s)", s, string(s))
}
+func (s Any) String() string {
+ return fmt.Sprintf("%T", s)
+}
+
+func (s Any) Match(string) bool {
+ return true
+}
+
+func (s Never) Match(string) bool {
+ return false
+}
+
+func (s Never) String() string {
+ return fmt.Sprintf("%T", s)
+}
+
type andMatcher struct {
matchers []StringMatcher
}
return nil, errors.New("regexp matcher may not have sub-rules")
}
return Regexp(m.Value), nil
+ case "any":
+ if m.Value != "" || len(m.Rules) != 0 {
+ return nil, errors.New("any matcher does not accept a value or sub-rules")
+ }
+ return Any{}, nil
+ case "never":
+ if m.Value != "" || len(m.Rules) != 0 {
+ return nil, errors.New("never matcher does not accept a value or sub-rules")
+ }
+ return Never{}, nil
case "and":
if m.Value != "" {
return nil, errors.New("\"and\" matcher may not have a unary value")