Add Not
filter to FilterType
To invert the result of filters.
This commit is contained in:
parent
4d39488c32
commit
9c423b8dc8
2 changed files with 19 additions and 2 deletions
|
@ -93,6 +93,7 @@ impl JsonFilter {
|
|||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields, rename_all = "lowercase")]
|
||||
pub enum FilterType {
|
||||
Not(Box<FilterType>),
|
||||
And(Vec<FilterType>),
|
||||
Or(Vec<FilterType>),
|
||||
#[serde(rename = "json")]
|
||||
|
@ -102,6 +103,7 @@ pub enum FilterType {
|
|||
impl FilterType {
|
||||
pub fn evaluate(&self, data: &serde_json::Value) -> Result<bool, WebhookeyError> {
|
||||
match self {
|
||||
FilterType::Not(filter) => Ok(!filter.evaluate(data)?),
|
||||
FilterType::And(filters) => {
|
||||
let (mut results, mut errors) = (Vec::new(), Vec::new());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue