jsonlogic_rs

A JsonLogic implementation in Rust.
To use this library, add
[]
= "0.5"
to your Cargo.toml.
Usage
use ;
let rule = json!;
let data = json!;
assert_eq!;
let data = json!;
assert_eq!;
See the examples directory for more usage examples.
Operations
jsonlogic_rs supports all JsonLogic operations. For detailed informations about all operations and their arguments, head over to Supported Operations on jsonlogic.com.
For Rust usage examples and edge cases have a look at the linked tests for each operator below.
- Accessing Data
- Logic and Boolean Operations
- Numeric Operations
- Array Operations
- String Operations
- Miscellaneous
- Juspay Version Comparision
Validation
The library now includes a validation module to ensure JSON Logic rules conform to your requirements:
use ;
use json;
// Create a validation configuration
let config = ValidationConfig ;
// Validate a rule
let rule = json!;
match validate
The validation module lets you:
- Require rules to be wrapped in an 'and' block (with option to allow empty rules)
Future versions will include more validation options, such as:
- Restrict which operators can be used
- Limit the depth of the rule's expression tree
- Control which variables can be accessed
- Ensure required variables are present
- Apply custom validation logic