Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/src/workflow/action/group.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Each selector is a **table** with only one of the following keys:
* `condition`: An array of three elements: The *JSON pointer*, *the operator*, and the
*operand*. The [JSON pointer](../../guide/concepts/json-pointers.md) references a
specific portion of the directory's value. The operator may be `"<"`, `"<="`,
`"=="`, `">="`, or `">"`. Both operands **must** have the same data type. The element
`"=="`, `"!="`, `">="`, or `">"`. Both operands **must** have the same data type. The element
referenced by each JSON pointer must be present in the value of **every** directory.
* `all`: Array of conditions (see above). All conditions must be `true` for this selector
to be `true`. `all` is evaluated with short-circuit logic. When an element in `all`
Expand Down
17 changes: 17 additions & 0 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ pub(crate) fn evaluate_json_comparison(
(Comparison::LessThan, Some(Ordering::Less)) => Some(true),
(Comparison::LessThanOrEqualTo, Some(Ordering::Less | Ordering::Equal)) => Some(true),
(Comparison::EqualTo, Some(Ordering::Equal)) => Some(true),
(Comparison::NotEqualTo, Some(Ordering::Less | Ordering::Greater)) => Some(true),
(Comparison::GreaterThanOrEqualTo, Some(Ordering::Greater | Ordering::Equal)) => Some(true),
(Comparison::GreaterThan, Some(Ordering::Greater)) => Some(true),
(_, None) => None,
Expand Down Expand Up @@ -165,6 +166,22 @@ mod tests {
evaluate_json_comparison(&Comparison::EqualTo, &Value::from(5), &Value::from(5)),
Some(true)
);
assert_eq!(
evaluate_json_comparison(&Comparison::NotEqualTo, &Value::from(5), &Value::from(10)),
Some(true)
);
assert_eq!(
evaluate_json_comparison(&Comparison::NotEqualTo, &Value::from(5), &Value::from(5)),
Some(false)
);
assert_eq!(
evaluate_json_comparison(
&Comparison::NotEqualTo,
&Value::from(5),
&Value::from("abcd")
),
None
);
assert_eq!(
evaluate_json_comparison(
&Comparison::GreaterThanOrEqualTo,
Expand Down
2 changes: 2 additions & 0 deletions src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ pub enum Comparison {
LessThanOrEqualTo,
#[serde(rename(deserialize = "=="))]
EqualTo,
#[serde(rename(deserialize = "!="))]
NotEqualTo,
#[serde(rename(deserialize = ">="))]
GreaterThanOrEqualTo,
#[serde(rename(deserialize = ">"))]
Expand Down