---
sidebar:
  hidden: true
title: roboto.domain.triggers.validation
---
## Module Contents

### TriggerValidator

```python
class roboto.domain.triggers.validation.TriggerValidator(
    catalog: roboto.domain.platform_events.PlatformEventCatalog = DEFAULT_PLATFORM_EVENT_CATALOG,
)
```

`from roboto.domain.triggers import TriggerValidator`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/validation.py#L44-L289)

Checker for the rules that span a trigger's source, condition and targets.

Roboto runs these checks whenever a trigger is created or updated, and rejects a trigger that fails one with `RobotoInvalidRequestException` carrying the check's message, so a trigger that could never fire or never fill in its templates is refused when it is saved. Call `validate` to run the same checks before saving a trigger.

A trigger passes when:

- Its event subscription names at least one platform event, and each is a type the catalog knows, that triggers may subscribe to, and that supports the subscription's `once_per`. All are about the same kind of entity.
- Each condition field names a root that every subscribed event exposes, or `envelope` or `trigger`, which every firing has. No field names `topic.` or `msgpath.`, and a field that names no root is allowed only when every subscribed event has the same default root.
- It has at least one target, and each `target_id` is unique within it.
- An action target sets `required_inputs` or `additional_inputs` only when every subscribed event exposes `dataset`, because those patterns match files of the event's dataset.
- An action target on events about a file sets `required_inputs` unless `once_per` is [`Dataset`](/docs/reference/python-sdk/roboto/domain/platform_events/once_per#roboto.domain.platform_events.once_per.OncePer.Dataset) or an ingestion rule manages the trigger, because the event's file is the action's input and must match one of them.
- Every `{{<name>}}` placeholder in an `invocation_input` query sits inside a quoted value.
- Every placeholder in a target names a root that every subscribed event exposes, or `envelope` or `trigger`.

A schedule fires for one platform event type, [`ScheduleFired`](/docs/reference/python-sdk/roboto/domain/platform_events/events#roboto.domain.platform_events.events.PlatformEventType.ScheduleFired), so the same checks apply to it with that type's roots.

**Parameters**

- **catalog** (`roboto.domain.platform_events.PlatformEventCatalog`): Descriptors of the platform event types, which give each type's roots and supported `once_per` values. Defaults to [`DEFAULT_PLATFORM_EVENT_CATALOG`](/docs/reference/python-sdk/roboto/domain/platform_events/catalog#roboto.domain.platform_events.catalog.DEFAULT_PLATFORM_EVENT_CATALOG).

#### TriggerValidator.validate()

```python
def validate(
    *,
    fires_on: roboto.domain.triggers.sources.TriggerSource,
    condition: Optional[roboto.query.ConditionType],
    targets: collections.abc.Sequence[roboto.domain.triggers.targets.TriggerTargetSpec],
    managed_by: Optional[roboto.domain.triggers.record.ManagedBy] = None,
) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/validation.py#L94-L122)

Reject a trigger whose source, condition or targets break a rule, raising at the first rule that fails.

**Parameters**

- **fires_on** (`roboto.domain.triggers.sources.TriggerSource`): What makes the trigger fire: an [`EventSubscription`](/docs/reference/python-sdk/roboto/domain/triggers/sources#roboto.domain.triggers.sources.EventSubscription) or a [`Schedule`](/docs/reference/python-sdk/roboto/domain/triggers/sources#roboto.domain.triggers.sources.Schedule).
- **condition** (`Optional[roboto.query.ConditionType]`): Condition over the variables a firing exposes. `None` skips the condition checks.
- **targets** (`collections.abc.Sequence[roboto.domain.triggers.targets.TriggerTargetSpec]`): Targets the trigger runs when it fires.
- **managed_by** (`Optional[roboto.domain.triggers.record.ManagedBy]`): Owner that manages the trigger, or `None` if the organization's members manage it. A trigger an ingestion rule manages runs only on the files the rule's path patterns match, so its action targets on events about a file need no `required_inputs`.

**Raises**

- `ValueError`: A rule fails. The message names the field, root, or event at fault.

**Returns**

- `None`

#### TriggerValidator.validate_record()

```python
def validate_record(record: roboto.domain.triggers.record.TriggerRecord) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/triggers/validation.py#L79-L92)

Reject a trigger record that breaks one of the rules `validate` checks.

It has no failures of its own; the `ValueError` that `validate` raises when a rule fails applies.

**Parameters**

- **record** (`roboto.domain.triggers.record.TriggerRecord`): Trigger record to check.

**Returns**

- `None`
