mirror of
https://github.com/vegu-ai/talemate.git
synced 2026-09-02 12:09:31 +02:00
227 lines
7.3 KiB
Markdown
227 lines
7.3 KiB
Markdown
|
|
# Validation Nodes
|
||
|
|
|
||
|
|
Validate values inside graphs — set/unset checks, containment, characters, asset IDs and context ID strings/items — producing pass/fail results you can branch on.
|
||
|
|
|
||
|
|
<!-- glossary:generated - everything below this line is generated by `python -m talemate.game.engine.nodes.tools glossary --write` - do not edit -->
|
||
|
|
|
||
|
|
|
||
|
|
_7 nodes._
|
||
|
|
|
||
|
|
| Node | Registry path |
|
||
|
|
| --- | --- |
|
||
|
|
| [Validate Asset ID](#validate-asset-id) | `validation/ValidateAssetID` |
|
||
|
|
| [Validate Character](#validate-character) | `validation/ValidateCharacter` |
|
||
|
|
| [Validate Context ID Item](#validate-context-id-item) | `validation/ValidateContextIDItem` |
|
||
|
|
| [Validate Context ID String](#validate-context-id-string) | `validation/ValidateContextIDString` |
|
||
|
|
| [Validate Value Contained](#validate-value-contained) | `validation/ValidateValueContained` |
|
||
|
|
| [Validate Value Is Not Set](#validate-value-is-not-set) | `validation/ValidateValueIsNotSet` |
|
||
|
|
| [Validate Value Is Set](#validate-value-is-set) | `validation/ValidateValueIsSet` |
|
||
|
|
|
||
|
|
## Validate Asset ID
|
||
|
|
|
||
|
|
`validation/ValidateAssetID`
|
||
|
|
|
||
|
|
Validate that a value is the ID of an existing scene asset, raising an
|
||
|
|
error if it isn't.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The asset ID to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The validated asset ID, passed through |
|
||
|
|
| `asset` | `asset` | The asset object |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
|
||
|
|
## Validate Character
|
||
|
|
|
||
|
|
`validation/ValidateCharacter`
|
||
|
|
|
||
|
|
Validate that a value is the name of a character in the scene, raising an
|
||
|
|
error if it isn't.
|
||
|
|
|
||
|
|
Optionally restrict to active or inactive characters, or create a
|
||
|
|
placeholder character when the name doesn't exist.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The character name to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The validated character name, passed through |
|
||
|
|
| `character` | `character` | The character object (or placeholder) |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
| `character_status` | `str` | `"all"` | The status of the character. Choices: `active`, `inactive`, `all`. |
|
||
|
|
| `create_placeholder` | `bool` | `False` | Whether to create a placeholder character if the character does not exist |
|
||
|
|
|
||
|
|
## Validate Context ID Item
|
||
|
|
|
||
|
|
`validation/ValidateContextIDItem`
|
||
|
|
|
||
|
|
Validate that a value is a context ID string that resolves to an existing
|
||
|
|
context ID item, raising an error if it doesn't.
|
||
|
|
|
||
|
|
Surrounding backticks and whitespace are stripped before validation. On
|
||
|
|
success the resolved item and its details are provided as outputs.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The context ID string to validate and resolve |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The cleaned, validated context ID string |
|
||
|
|
| `context_id` | `context_id` | The context ID of the resolved item |
|
||
|
|
| `context_id_item` | `context_id_item` | The resolved context ID item |
|
||
|
|
| `context_type` | `str` | The context type of the resolved item |
|
||
|
|
| `context_value` | `any` | The current value stored at the context ID |
|
||
|
|
| `name` | `str` | The name of the resolved item |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
|
||
|
|
## Validate Context ID String
|
||
|
|
|
||
|
|
`validation/ValidateContextIDString`
|
||
|
|
|
||
|
|
Validate that a value is a valid context ID string, raising an error if it
|
||
|
|
isn't.
|
||
|
|
|
||
|
|
Surrounding backticks and whitespace are stripped before validation, and
|
||
|
|
the cleaned string is passed through on success.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The context ID string to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The cleaned, validated context ID string |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
|
||
|
|
## Validate Value Contained
|
||
|
|
|
||
|
|
`validation/ValidateValueContained`
|
||
|
|
|
||
|
|
Validate that a value is contained in a list or dictionary, raising an
|
||
|
|
error if it isn't.
|
||
|
|
|
||
|
|
For dictionaries, containment is checked against the keys.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The value to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
| `list` | `list,dict` | The list or dictionary to check containment against |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The validated value, passed through |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
|
||
|
|
## Validate Value Is Not Set
|
||
|
|
|
||
|
|
`validation/ValidateValueIsNotSet`
|
||
|
|
|
||
|
|
Validate that a value is NOT set, raising an error if it is.
|
||
|
|
|
||
|
|
A value counts as unset when it is null, unresolved or a blank string.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The value to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The (unset) value, passed through |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
|
||
|
|
## Validate Value Is Set
|
||
|
|
|
||
|
|
`validation/ValidateValueIsSet`
|
||
|
|
|
||
|
|
Validate that a value is set, raising an error if it isn't.
|
||
|
|
|
||
|
|
A value counts as unset when it is null, unresolved or - when
|
||
|
|
`blank_string_is_unset` is true - a blank string. Other falsy values
|
||
|
|
(0, false) count as set. On success the value is passed through.
|
||
|
|
|
||
|
|
**Inputs**
|
||
|
|
|
||
|
|
| Input | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The value to validate |
|
||
|
|
| `error_message` | `str` | Custom error message, `{value}` is replaced with the value (optional) |
|
||
|
|
|
||
|
|
**Outputs**
|
||
|
|
|
||
|
|
| Output | Type | Description |
|
||
|
|
| --- | --- | --- |
|
||
|
|
| `value` | `any` | The validated value, passed through |
|
||
|
|
|
||
|
|
**Properties**
|
||
|
|
|
||
|
|
| Property | Type | Default | Description |
|
||
|
|
| --- | --- | --- | --- |
|
||
|
|
| `error_message` | `str` | `""` | The error message to raise. Use {value} to reference the value that is not set. |
|
||
|
|
| `blank_string_is_unset` | `bool` | `True` | If true, a blank string will be considered unset |
|