Function apply

Source
pub fn apply(v: &Value, filters: &[Filter<'_>]) -> bool
Expand description

Applies a set of filters on a JSON Value and returns whether the Value passes the filters.

The function iterates over a list of filters and applies each filter on the Value v. The field to be compared is extracted from the Value, based on the field attribute of the filter. The value to compare with is determined based on the value_field or value attributes of the filter.

The comparison is done either as a string comparison or as a number comparison, depending on the types of the extracted field and value. For number comparisons, a multiplier can be applied to the field or value.

If a filter comparison is unsuccessful, the function immediately returns false. If all filter comparisons are successful, the function returns true.

§Arguments

  • v - The JSON Value to apply the filters on.
  • filters - A slice of Filters to apply on the Value.

§Returns

  • bool - Returns true if the Value v passes all the filters, otherwise returns false.