Lex::Conditioner

Conditioner is an extension that can check conditions of the previous results to determine if the relationship should continue. It gives you the ability to have an unlimited number of nested ANDs + ORs to make complete conditions

Conditions are added to the relationships table under the conditions column and are formatted in json.

Nested values are translated to dot patterns


Matchers

equal?(fact, value, values) # are the two values equal including class not_equal?(fact, value, values) # are the two values no equal nil?(fact, values) # checks if the value doesn't exist not_nil?(fact, values) # checks if the value exists is_false?(fact, values) # checks if the value is false is_true?(fact, values) # checks if the value if true is_array?(fact, values) # checks if the value is an array is_string?(fact, values) # checks if the value is a string is_integer(fact, values) # checks if the value is a number

The operator when creating conditions is equal to the method name without the ? so equal? becomes equal, is_true? becomes is_true

Examples

In the first example, the pet type must be dog and the pet must be hungry

{ "all": [{ "fact": "pet.type", "value": "dog", "operator": "equal" },{ "fact":"pet.hungry", "operator":"is_true" }] }

All of these scenarios would fail the conditioner

{ "pet": { "type":"cat", "hungry":true } } { "pet": { "type":"dog", "hungry":false } } { "pet": { "type":"dog", "hungry":"true" } } { "person": { "hungry":true } }

This scenario would pass

 

In the second scenario, the pet must be a dog or a cat using an OR condition

Example payloads

 

The last scenario is a combination of ands and ors

Example Payloads

 

Â