-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from codetiger/main
Added PreserveOperator and fix for Dot paths
- Loading branch information
Showing
7 changed files
with
102 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use crate::operators::operator::Operator; | ||
use crate::{Error, JsonLogic, JsonLogicResult}; | ||
use serde_json::Value; | ||
|
||
#[derive(Default)] | ||
pub struct PreserveOperator; | ||
|
||
impl Operator for PreserveOperator { | ||
fn apply(&self, _logic: &JsonLogic, args: &Value, _data: &Value) -> JsonLogicResult { | ||
match args { | ||
Value::Object(obj) => Ok(Value::Object(obj.clone())), | ||
_ => Err(Error::InvalidArguments("preserve requires object argument".into())) | ||
} | ||
} | ||
|
||
// Optionally disable auto traversal since we want to preserve the raw value | ||
fn auto_traverse(&self) -> bool { | ||
false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters