roboto.domain.triggers.validation#
Module Contents#
- class roboto.domain.triggers.validation.TriggerValidator(catalog=DEFAULT_PLATFORM_EVENT_CATALOG)#
Save-time validation for triggers.
Enforces the cross-field rules that need the event catalog: a condition may only reference namespace roots exposed by every event the source fires for,
once_permust be legal for every subscribed event, every target must act on the kind of entity the subscription is about, and every target template placeholder must resolve to a shared exposed root (or a reservedenvelope./trigger.context). A schedule fires for exactly one occurrence type, so the same rules apply to it with that occurrence’s roots.Run before persistence so a trigger that could never fire — or could never resolve its templates — fails loudly with an actionable message instead of silently misbehaving at evaluation time.
- Parameters:
catalog (roboto.domain.platform_events.PlatformEventCatalog)
- validate(*, fires_on, condition, targets)#
Validate the cross-field rules for one trigger’s parts.
- Parameters:
fires_on (roboto.domain.triggers.sources.TriggerSource) – The trigger’s firing source.
condition (Optional[roboto.query.ConditionType]) – Optional predicate over the firing’s namespace.
targets (collections.abc.Sequence[roboto.domain.triggers.targets.TriggerTargetSpec]) – The trigger’s target specs.
- Raises:
ValueError – The first rule that fails, with a message naming the offending field, root, or event.
- Return type:
None
- validate_record(record)#
Validate a full trigger record.
- Raises:
ValueError – Any rule in
validate()fails.- Parameters:
- Return type:
None