TinyRuleKit
Trigger Guards
Use triggerGuards when every rule under one trigger shares the same precondition.
A guard is checked once when that trigger is fired internally. If it fails, the engine returns before evaluating any matching rule conditions or actions.
JSON
{
"triggerGuards": [
{
"trigger": "PLAYER_JOINED",
"conditions": [
{
"type": "LEVEL_AT_LEAST",
"params": {
"level": 5
}
}
]
}
],
"rules": [
{
"trigger": "PLAYER_JOINED",
"conditions": [
{
"type": "HAS_PERMISSION",
"params": {
"permission": "vip"
}
}
],
"actions": [
{
"type": "GIVE_COINS",
"params": {
"amount": 25
}
}
]
}
]
}
The guard conditions use the same condition shape as rules: static conditions, expression conditions,
operators, ref, and !ref.
When To Use
- use a guard for trigger-wide preconditions
- use rule conditions for rule-specific matching
- use action
whenguards for action-specific checks
Do not use a trigger guard to hide unrelated business rules. It should answer whether the trigger should continue at all.