pub struct RuleBuilder<'a> { /* private fields */ }Expand description
Main builder for creating JSONLogic rules.
This is the entry point for the builder API, providing access to different specialized builders for different types of operations.
Implementations§
Source§impl<'a> RuleBuilder<'a>
impl<'a> RuleBuilder<'a>
Sourcepub fn compare(&self) -> ComparisonBuilder<'a>
pub fn compare(&self) -> ComparisonBuilder<'a>
Creates a comparison builder.
Sourcepub fn arithmetic(&self) -> ArithmeticBuilder<'a>
pub fn arithmetic(&self) -> ArithmeticBuilder<'a>
Creates an arithmetic builder.
Sourcepub fn control(&self) -> ControlBuilder<'a>
pub fn control(&self) -> ControlBuilder<'a>
Creates a control flow builder.
Sourcepub fn array(&self) -> ArrayBuilder<'a>
pub fn array(&self) -> ArrayBuilder<'a>
Creates an array operation builder.
Sourcepub fn string_ops(&self) -> StringBuilder<'a>
pub fn string_ops(&self) -> StringBuilder<'a>
Creates a string operation builder.
Sourcepub fn datetime(&self) -> DateTimeBuilder<'a>
pub fn datetime(&self) -> DateTimeBuilder<'a>
Creates a datetime operation builder.
Sourcepub fn var(&self, path: &str) -> VariableBuilder<'a>
pub fn var(&self, path: &str) -> VariableBuilder<'a>
Creates a variable reference.
Sourcepub fn val_op<T: Into<DataValue<'a>>>(&self, path: T) -> Logic<'a>
pub fn val_op<T: Into<DataValue<'a>>>(&self, path: T) -> Logic<'a>
Creates a val token with the given path components. The path can be a string, number, or array of components.
Sourcepub fn val_path<I, T>(&self, components: I) -> Logic<'a>
pub fn val_path<I, T>(&self, components: I) -> Logic<'a>
Creates a val token with an array of path components. Each component can be a string or number for array indices.
Sourcepub fn string_value(&self, value: &str) -> Logic<'a>
pub fn string_value(&self, value: &str) -> Logic<'a>
Creates a literal string value.
Sourcepub fn var_with_default(&self, path: &str, default: Logic<'a>) -> Logic<'a>
pub fn var_with_default(&self, path: &str, default: Logic<'a>) -> Logic<'a>
Creates a logic that gets a variable and returns a default if it doesn’t exist.
Sourcepub fn missing_op<T: Into<Logic<'a>>>(&self, variables: T) -> Logic<'a>
pub fn missing_op<T: Into<Logic<'a>>>(&self, variables: T) -> Logic<'a>
Creates a missing check for the specified variables. Returns an array of variables that are missing from the data context.
Sourcepub fn missing_var(&self, variable: &str) -> Logic<'a>
pub fn missing_var(&self, variable: &str) -> Logic<'a>
Creates a missing check for a single variable.
Sourcepub fn missing_vars<I, S>(&self, variables: I) -> Logic<'a>
pub fn missing_vars<I, S>(&self, variables: I) -> Logic<'a>
Creates a missing check for multiple variables.
Sourcepub fn missing_some_op<T: Into<Logic<'a>>>(
&self,
min_required: i64,
variables: T,
) -> Logic<'a>
pub fn missing_some_op<T: Into<Logic<'a>>>( &self, min_required: i64, variables: T, ) -> Logic<'a>
Creates a missing_some check, which returns an array of variables that are missing from the data context if the number of present variables is less than the required number.
Sourcepub fn throw_op<T: Into<Logic<'a>>>(&self, error: T) -> Logic<'a>
pub fn throw_op<T: Into<Logic<'a>>>(&self, error: T) -> Logic<'a>
Creates a throw operator that throws an error with the given value.
Sourcepub fn try_op<I, T>(&self, expressions: I) -> Logic<'a>
pub fn try_op<I, T>(&self, expressions: I) -> Logic<'a>
Creates a try operator that attempts to evaluate a sequence of expressions. Returns the result of the first one that succeeds. If all expressions fail, the last error is propagated.
Sourcepub fn type_op(&self) -> TypeBuilder<'a>
pub fn type_op(&self) -> TypeBuilder<'a>
Create a type operator that returns the type of a value