Documentation ¶
Index ¶
- Constants
- func Must(input string, filters ...Filter) bool
- type Filter
- func Contains(targets []string) Filter
- func Equal(targets []string) Filter
- func Fail() Filter
- func Greater(targets []string) Filter
- func Identity(id string) Filter
- func In(targets []string) Filter
- func Less(targets []string) Filter
- func NotContains(targets []string) Filter
- func NotEqual(targets []string) Filter
- func NotGreater(targets []string) Filter
- func NotIn(targets []string) Filter
- func NotLess(targets []string) Filter
- func NotPathContains(targets []string) Filter
- func NotPathEquals(targets []string) Filter
- func NotPathPrefix(targets []string) Filter
- func NotPathSuffix(targets []string) Filter
- func NotPrefix(targets []string) Filter
- func NotStrictEqual(targets []string) Filter
- func NotSuffix(targets []string) Filter
- func Pass() Filter
- func PathContains(targets []string) Filter
- func PathEquals(targets []string) Filter
- func PathPrefix(targets []string) Filter
- func PathSuffix(targets []string) Filter
- func Prefix(targets []string) Filter
- func StrictEqual(targets []string) Filter
- func Suffix(targets []string) Filter
Constants ¶
const ( UnknownComparator comparator = "" // norm(a) == norm(b) EqualTo = "EQ" // a === b StrictEqualTo = "StrictEQ" // a > b GreaterThan = "GT" // a < b LessThan = "LT" // "foo,bar,baz" contains "foo" TargetContains = "Cont" // "foo" is found in "foo,bar,baz" TargetIn = "IN" // always passes Passes = "Pass" // always fails Fails = "Fail" // passthrough for the target IdentityValue = "Identity" // "foo" is a prefix of "foobarbaz" TargetPrefixes = "Pfx" // "baz" is a suffix of "foobarbaz" TargetSuffixes = "Sfx" // "foo" equals any complete element prefix of "foo/bar/baz" TargetPathPrefix = "PathPfx" // "foo" equals any complete element in "foo/bar/baz" TargetPathContains = "PathCont" // "baz" equals any complete element suffix of "foo/bar/baz" TargetPathSuffix = "PathSfx" // "foo/bar/baz" equals the complete path "foo/bar/baz" TargetPathEquals = "PathEQ" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Filter ¶
type Filter struct { Comparator comparator `json:"comparator_type"` // the type of comparison Targets []string `json:"targets"` // the set of values to compare NormalizedTargets []string `json:"normalizedTargets"` // the set of comparable values post normalization Negate bool `json:"negate"` // when true, negate the comparator result // only used when the filter's purpose is to hold a value without intent for comparison Identity string `json:"identity"` // deprecated, kept around for deserialization Target string `json:"target"` // the value to compare against ComparatorInt int `json:"comparator"` }
Filter contains a comparator func and the target to compare values against. Filter.Matches(v) returns true if Filter.Comparer(filter.target, v) is true.
func Contains ¶
Contains creates a filter f where f.Compare(v) is true if, for any target t in f, t.Contains(v)
func Greater ¶
Greater creates a filter f where f.Compare(v) is true if, for any target t in f, t > v
func Identity ¶
Identity creates a filter intended to hold values, rather than compare them. Comparatively, it'll behave the same as Equals.
func NotContains ¶
NotContains creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Contains(v)
func NotEqual ¶
NotEqual creates a filter f where f.Compare(v) is true if, for any target t in f, t != v
func NotGreater ¶
NotGreater creates a filter f where f.Compare(v) is true if, for any target t in f, t <= v
func NotIn ¶
NotIn creates a filter f where f.Compare(v) is true if, for any target t in f, !v.Contains(t)
func NotLess ¶
NotLess creates a filter f where f.Compare(v) is true if, for any target t in f, t >= v
func NotPathContains ¶
NotPathContains creates a filter f where f.Compare(v) is true if, for any target t in f, for _every_ elem e in split(v), !t.Equals(e) || for _every_ sequence of elems in split(v), !t.Equals(path.Join(e[n:m])) ex: t="foo" returns false for v="/baz/foo/bar", but true for v="/baz/foobar" ex: t="baz/foo" returns false for v="/baz/foo/bar", but true for v="/baz/foobar"
func NotPathEquals ¶
NotPathEquals creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Equals(v) || !split(t)[i].Equals(split(v)[i]) for _all_ i in 0..len(t)-1 ex: t="foo" returns true v="/foo/bar", v="bar/foo/", and v="/foobar/" but false for for v="/foo/", v="/foo", and v="foo/"
func NotPathPrefix ¶
NotPathPrefix creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Prefix(v) || !split(t)[i].Equals(split(v)[i]) for _any_ i in 0..len(t)-1 ex: t="/foo/bar" returns false for v="/foo/bar/baz", but true for v="/foo/barbaz"
func NotPathSuffix ¶
NotPathSuffix creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Suffix(v) || !split(t)[i].Equals(split(v)[i]) for _any_ i in 0..len(t)-1 ex: t="/bar/baz" returns false for v="/foo/bar/baz", but true for v="/foobar/baz"
func NotPrefix ¶
NotPrefix creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Prefix(v)
func NotStrictEqual ¶
NotStrictEqual creates a filter f where f.Compare(v) is true if, for any target t in f, t !== v. t and v are not normalized for this comparison. The comparison is case sensitive and ignores character folding.
func NotSuffix ¶
NotSuffix creates a filter f where f.Compare(v) is true if, for any target t in f, !t.Suffix(v)
func PathContains ¶
PathContains creates a filter f where f.Compare(v) is true if, for any target t in f, for _any_ elem e in split(v), t.Equals(e) || for _any_ sequence of elems in split(v), t.Equals(path.Join(e[n:m])) ex: t="foo" returns true for v="/baz/foo/bar", but false for v="/baz/foobar" ex: t="baz/foo" returns true for v="/baz/foo/bar", but false for v="/baz/foobar"
func PathEquals ¶
PathEquals creates a filter f where f.Compare(v) is true if, for any target t in f, t.Equals(v) && split(t)[i].Equals(split(v)[i]) for _all_ i in 0..len(t)-1 ex: t="foo" returns true for v="/foo/", v="/foo", and v="foo/" but false for v="/foo/bar", v="bar/foo/", and v="/foobar/"
func PathPrefix ¶
PathPrefix creates a filter f where f.Compare(v) is true if, for any target t in f, t.Prefix(v) && split(t)[i].Equals(split(v)[i]) for _all_ i in 0..len(t)-1 ex: t="/foo/bar" returns true for v="/foo/bar/baz", but false for v="/foo/barbaz"
func PathSuffix ¶
PathSuffix creates a filter f where f.Compare(v) is true if, for any target t in f, t.Suffix(v) && split(t)[i].Equals(split(v)[i]) for _all_ i in 0..len(t)-1 ex: t="/bar/baz" returns true for v="/foo/bar/baz", but false for v="/foobar/baz"
func Prefix ¶
Prefix creates a filter f where f.Compare(v) is true if, for any target t in f, t.Prefix(v)
func StrictEqual ¶
StrictEqual creates a filter f where f.Compare(v) is true if, for any target t in f, t === v. t and v are not normalized for this comparison. The comparison is case sensitive and ignores character folding.
func Suffix ¶
Suffix creates a filter f where f.Compare(v) is true if, for any target t in f, t.Suffix(v)
func (Filter) CompareAny ¶
CompareAny checks whether any one of all the provided inputs passes the filter.
Note that, as a gotcha, CompareAny can resolve truthily for both the standard and negated versions of a filter. Ex: consider the input CompareAny(true, false), which will return true for both Equals(true) and NotEquals(true), because at least one element matches for both filters.