Skip to content

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:

  1. ns.myvar[“complex-value”]
  2. ns.myvar[“complex-value”][0]
  3. 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.

new AttributePattern(variableValue): AttributePattern

variableValue stores the fully-qualified variable name for the pattern.

string

AttributePattern

qualBool(pattern): AttributePattern

QualBool adds a bool qualifier pattern for a map index operation to the AttributePattern.

boolean

AttributePattern


qualifierPatterns(): AttributeQualifierPattern[]

QualifierPatterns returns the set of AttributeQualifierPattern values on the AttributePattern.

AttributeQualifierPattern[]


qualInt(pattern): AttributePattern

QualInt adds an int qualifier pattern to the AttributePattern.

The index may be either a map or list index.

number | bigint | Int

AttributePattern


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.

string

AttributePattern


qualUint(pattern): AttributePattern

QualUint adds a uint qualifier pattern for a map index operation to the AttributePattern.

bigint | Uint

AttributePattern


variable(): string

Variable returns the fully-qualified variable name for the pattern.

string


variableMatches(variable): boolean

VariableMatches returns true if the fully qualified variable matches the AttributePattern fully qualified variable name.

string

boolean


wildcard(): AttributePattern

Wildcard adds a special sentinel qualifier pattern that will match any single qualifier.

AttributePattern