reject
Syntax
Shorthand syntax
- reject: constant
Extended syntax
- reject:
value: constant
Pattern variant syntax
- reject:
pattern: regular expression
Expression variant syntax
- reject:
expression: expression
Description
The reject operation works on arrays, testing each element in the array by matching it against a constant value, matching it against a regular expression, or evaluating an expression. For each element where the test passes, the element will be rejected, and removed from the array.
The value parameter is a constant value, such as a string. Value is also supported in a shorthand format. The incoming elements are tested by comparing against this value for equality.
The pattern parameter is an optional alternative to value, and should be a regular expression. Regular expressions are surrounded in forward slashes (/). The incoming elements will be tested by testing the regular expression against it for a match.
The expression parameter is an optional alternative to value, and can be an arbitrary expression that references other identifiers in the script. The expression supports the this keyword to reference the array element, but does not need to. The expression is evaluated for each element in the array and any time one of the variables in the expression itself change.
Examples
- AdapterScript
var1:
- source: alarm-list
- reject:
expression: this.level == 'warn'
In the above example, alarm-list
is an identifier from another part of the adapter script.