matcher

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchPathPattern

func MatchPathPattern(pattern, path string) (bool, error)

MatchPathPattern given string with path pattern The prefix syntax is:

prefix:
  { term }
term:
  '*'         matches any sequence of non-path-separators
  '**'        matches any sequence of characters, including
              path separators.
  '?'         matches any single non-path-separator character
  '[' [ '^' ] { character-range } ']'
        character class (must be non-empty)
  '{' { term } [ ',' { term } ... ] '}'
  c           matches character c (c != '*', '?', '\\', '[')
  '\\' c      matches character c

character-range:
  c           matches character c (c != '\\', '-', ']')
  '\\' c      matches character c
  lo '-' hi   matches character c for lo <= c <= hi

func MatchPrefix

func MatchPrefix(prefix, value string, caseInsensitive bool) (bool, error)

func MatchRegex

func MatchRegex(regex, value string) (bool, error)

func MatchRegexPattern

func MatchRegexPattern(regex *regexp.Regexp, value string) (bool, error)

func MatchString

func MatchString(expected, actual string, caseInsensitive bool) bool

func MatchSubString

func MatchSubString(substr, actual string, caseInsensitive bool) bool

func MatchSuffix

func MatchSuffix(suffix, value string, caseInsensitive bool) (bool, error)

Types

type AndMatcher

type AndMatcher []Matcher

AndMatcher chain a list of matchers with AND operator

func (AndMatcher) And

func (m AndMatcher) And(matchers ...Matcher) ChainableMatcher

func (AndMatcher) Matches

func (m AndMatcher) Matches(i interface{}) (ret bool, err error)

func (AndMatcher) MatchesWithContext

func (m AndMatcher) MatchesWithContext(c context.Context, i interface{}) (ret bool, err error)

func (AndMatcher) Or

func (m AndMatcher) Or(matchers ...Matcher) ChainableMatcher

func (AndMatcher) String

func (m AndMatcher) String() string

type ChainableMatcher

type ChainableMatcher interface {
	Matcher
	// Or concat given matchers with OR operator
	Or(matcher ...Matcher) ChainableMatcher
	// And concat given matchers with AND operator
	And(matcher ...Matcher) ChainableMatcher
}

func And

func And(left Matcher, right ...Matcher) ChainableMatcher

And concat given matchers with AND operator

func Any

func Any() ChainableMatcher

Any returns a matcher that matches everything

func None

func None() ChainableMatcher

None returns a matcher that matches nothing

func Not

func Not(matcher Matcher) ChainableMatcher

Not returns a negated matcher

func Or

func Or(left Matcher, right ...Matcher) ChainableMatcher

Or concat given matchers with OR operator

type GenericMatcher

type GenericMatcher struct {
	// contains filtered or unexported fields
}

GenericMatcher implements ChainableMatcher TODO review use cases to determine if this class is necessary

func (*GenericMatcher) And

func (m *GenericMatcher) And(matchers ...Matcher) ChainableMatcher

func (*GenericMatcher) Matches

func (m *GenericMatcher) Matches(i interface{}) (bool, error)

func (*GenericMatcher) MatchesWithContext

func (m *GenericMatcher) MatchesWithContext(c context.Context, i interface{}) (ret bool, err error)

func (*GenericMatcher) Or

func (m *GenericMatcher) Or(matchers ...Matcher) ChainableMatcher

func (*GenericMatcher) String

func (m *GenericMatcher) String() string

type Matcher

type Matcher interface {
	Matches(interface{}) (bool, error)
	MatchesWithContext(context.Context, interface{}) (bool, error)
}

type NegateMatcher

type NegateMatcher struct {
	Matcher
}

NegateMatcher apply ! operator to embedded Matcher

func (*NegateMatcher) And

func (m *NegateMatcher) And(matchers ...Matcher) ChainableMatcher

func (*NegateMatcher) Matches

func (m *NegateMatcher) Matches(i interface{}) (ret bool, err error)

func (NegateMatcher) MatchesWithContext

func (m NegateMatcher) MatchesWithContext(c context.Context, i interface{}) (ret bool, err error)

func (*NegateMatcher) Or

func (m *NegateMatcher) Or(matchers ...Matcher) ChainableMatcher

func (NegateMatcher) String

func (m NegateMatcher) String() string

type NoopMatcher

type NoopMatcher bool

NoopMatcher matches stuff literally

func (NoopMatcher) And

func (m NoopMatcher) And(matchers ...Matcher) ChainableMatcher

func (NoopMatcher) Matches

func (m NoopMatcher) Matches(_ interface{}) (bool, error)

func (NoopMatcher) MatchesWithContext

func (m NoopMatcher) MatchesWithContext(context.Context, interface{}) (bool, error)

func (NoopMatcher) Or

func (m NoopMatcher) Or(matchers ...Matcher) ChainableMatcher

func (NoopMatcher) String

func (m NoopMatcher) String() string

type OrMatcher

type OrMatcher []Matcher

OrMatcher chain a list of matchers with OR operator

func (OrMatcher) And

func (m OrMatcher) And(matchers ...Matcher) ChainableMatcher

func (OrMatcher) Matches

func (m OrMatcher) Matches(i interface{}) (ret bool, err error)

func (OrMatcher) MatchesWithContext

func (m OrMatcher) MatchesWithContext(c context.Context, i interface{}) (ret bool, err error)

func (OrMatcher) Or

func (m OrMatcher) Or(matchers ...Matcher) ChainableMatcher

func (OrMatcher) String

func (m OrMatcher) String() string

type StringMatcher

type StringMatcher interface {
	ChainableMatcher
}

StringMatcher is a typed ChainableMatcher that accept String

func AnyNonEmptyString

func AnyNonEmptyString() StringMatcher

func WithPathPattern

func WithPathPattern(pattern string) StringMatcher

func WithPrefix

func WithPrefix(prefix string, caseInsensitive bool) StringMatcher

func WithRegex

func WithRegex(regex string) StringMatcher

func WithRegexPattern

func WithRegexPattern(regex *regexp.Regexp) StringMatcher

func WithString

func WithString(expected string, caseInsensitive bool) StringMatcher

func WithSubString

func WithSubString(substr string, caseInsensitive bool) StringMatcher

func WithSuffix

func WithSuffix(suffix string, caseInsensitive bool) StringMatcher

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL