Custom conditions
Custom conditions are user-defined conditions.
A custom condition will impact the atomic evaluation of each conditions (i.e., condition ids).
Vocabulary
To be more precise, a condition expression is something like:
1 |
|
In that example, the condition expression is made of 2 conditions whose condition ids are:
- CONDITION_1
- CONDITION_2
With the built-in condition (also named standard condition), condition ids map to validation functions and condition parameters but we can change that with a brand new custom condition.
A custom condition example:
1 |
|
Remember
condition ids have to be in CAPITAL LETTERS.
Imagine you want it to be interpreted as (pseudo-code):
With the custom conditions it's quite simple to implement.
Why use a custom condition?
The main goal is to simplify handling of recurrent conditions (e.i., "recurrent" meaning very similar conditions).
Class implementation
First, create a class inheriting from BaseCondtion
and implement the verify()
method as you want/need:
self.condition_id
self.condition_id
will be NAME_JOHN
for the first condition and AGE_42
for the second.
Good to know
The parsing_error_strategy
can be used by the developer to adapt exception handling behavior. Possible values:
1 2 3 |
|
Configuration
Last thing to do is to add your new custom condition in the configuration:
Class diagram
It is based on the following strategy pattern:
Good to know
The class StandardCondition
is the built-in implementation of a condition.