Comparators

Comparator operations are declared using JSON with following structure:

{"field": "<fieldname>", "operator", "<operator>", "value": "<comparison value>"}

Available operators

class rulez.operator.And(operator, engine, value, value_type=None)

Apply boolean AND condition to list of values

Operator:and
Value_types:list, tuple

Items in values have to be a compilable rulez operator JSON

class rulez.operator.Equal(operator, engine, field, value, value_type=None)

Compare whether contents of field is same as value

Operator:==
Value_types:rulez_operation, str, float, int
class rulez.operator.Get(operator, engine, value, value_type=None)

Get value from a field

Operator:get
Value_types:field_name
class rulez.operator.GreaterEqualThan(operator, engine, field, value, value_type=None)

Compare whether contents of field is greater equal than value

Operator:>=
Value_types:rulez_operation, str, float, int
class rulez.operator.GreaterThan(operator, engine, field, value, value_type=None)

Compare whether contents of field is greater than value

Operator:>
Value_types:rulez_operation, str, float, int
class rulez.operator.In(operator, engine, field, value, value_type=None)

Apply boolean OR condition to list of values

Operator:or
Value_types:list[rulez_operation], tuple[rulez_operation], list[str], list[float], list[int]
class rulez.operator.LessEqualThan(operator, engine, field, value, value_type=None)

Compare whether contents of field is less equal than value

Operator:<=
Value_types:rulez_operation, str, float, int
class rulez.operator.LessThan(operator, engine, field, value, value_type=None)

Compare whether contents of field is less than value

Operator:<
Value_types:rulez_operation, str, float, int
class rulez.operator.Like(operator, engine, field, value, value_type=None)

Compare whether contents of field is like value

Operator:~
Value_types:str
class rulez.operator.Match(operator, engine, field, value, value_type=None)

Compare whether contents of field matches value

Operator:match
Value_types:str

Warning

This operator only supported in sqlalchemy compiler.

class rulez.operator.NotEqual(operator, engine, field, value, value_type=None)

Compare whether contents of field is not equal to value

Operator:!=
Value_types:rulez_operation, str, float, int
class rulez.operator.Or(operator, engine, value, value_type=None)

Apply boolean OR condition to list of values

Operator:or
Value_types:list[rulez_operation], tuple[rulez_operation]

Items in values have to be a compilable rulez operation JSON

Comparing contents of 2 fields

We can also compare contents of 2 fields by using comparison operators

{
     "field": "<fieldname1>",
     "operator": "<operator>",
     "value": {
         "operator": "get",
         "value": "<fieldname2>"
      }
}