AttributePattern
AttributePattern represents a top-level variable with an optional set of qualifier patterns.
When using a CEL expression within a container, e.g. a package or namespace, the variable name
in the pattern must match the qualified name produced during the variable namespace resolution.
For example, if variable c appears in an expression whose container is a.b, the variable
name supplied to the pattern must be a.b.c
The qualifier patterns for attribute matching must be one of the following:
- valid map key type: string, int, uint, bool
- wildcard (*)
Examples:
- ns.myvar[“complex-value”]
- ns.myvar[“complex-value”][0]
- ns.myvar[“complex-value”].*.name
The first example is simple: match an attribute where the variable is ‘ns.myvar’ with a
field access on ‘complex-value’. The second example expands the match to indicate that only
a specific index 0 should match. And lastly, the third example matches any indexed access
that later selects the ‘name’ field.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AttributePattern(
variableValue):AttributePattern
variableValue stores the fully-qualified variable name for the pattern.
Parameters
Section titled “Parameters”variableValue
Section titled “variableValue”string
Returns
Section titled “Returns”AttributePattern
Methods
Section titled “Methods”qualBool()
Section titled “qualBool()”qualBool(
pattern):AttributePattern
QualBool adds a bool qualifier pattern for a map index operation to the AttributePattern.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”boolean
Returns
Section titled “Returns”AttributePattern
qualifierPatterns()
Section titled “qualifierPatterns()”qualifierPatterns():
AttributeQualifierPattern[]
QualifierPatterns returns the set of AttributeQualifierPattern values on the AttributePattern.
Returns
Section titled “Returns”qualInt()
Section titled “qualInt()”qualInt(
pattern):AttributePattern
QualInt adds an int qualifier pattern to the AttributePattern.
The index may be either a map or list index.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”number | bigint | Int
Returns
Section titled “Returns”AttributePattern
qualString()
Section titled “qualString()”qualString(
pattern):AttributePattern
QualString adds a string qualifier pattern to the AttributePattern.
The string may be a valid identifier, or string map key including empty string.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”string
Returns
Section titled “Returns”AttributePattern
qualUint()
Section titled “qualUint()”qualUint(
pattern):AttributePattern
QualUint adds a uint qualifier pattern for a map index operation to the AttributePattern.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”bigint | Uint
Returns
Section titled “Returns”AttributePattern
variable()
Section titled “variable()”variable():
string
Variable returns the fully-qualified variable name for the pattern.
Returns
Section titled “Returns”string
variableMatches()
Section titled “variableMatches()”variableMatches(
variable):boolean
VariableMatches returns true if the fully qualified variable matches the AttributePattern fully qualified variable name.
Parameters
Section titled “Parameters”variable
Section titled “variable”string
Returns
Section titled “Returns”boolean
wildcard()
Section titled “wildcard()”wildcard():
AttributePattern
Wildcard adds a special sentinel qualifier pattern that will match any single qualifier.
Returns
Section titled “Returns”AttributePattern