Validation¶
validate ¶
Optional checks on a layout, for things the format allows but TouchOSC won't like.
Validation is deliberately advisory and never raises. TouchOSC accepts properties it does not recognise -- that is what makes custom properties useful -- so a strict schema would reject valid layouts. What this catches instead is the narrower and more useful case: a property or value that is part of the format but belongs to a different control type, plus the few things TouchOSC genuinely cannot load.
Every rule below is corroborated against layouts the TouchOSC editor wrote; see
tests/test_validate.py, which requires every editor-written file in the corpus
to validate without errors.
Issue
dataclass
¶
One finding from validate.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
str
|
|
path |
str
|
Slash-separated control names from the root, for locating it. |
message |
str
|
What is wrong. |
Source code in src/py2tosc/validate.py
ValidationError ¶
Bases: Py2ToscError
Raised by save(validate=True) when a layout has errors.
Attributes:
| Name | Type | Description |
|---|---|---|
issues |
Every finding, not only the errors, so a caller catching this can report the warnings too. |
Source code in src/py2tosc/validate.py
validate ¶
Check a control tree for things TouchOSC will reject or ignore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Control | Document
|
required |
Local message destinations are resolved against target and nothing above
it, so validating a subtree that is wired to a control outside itself
reports a destination it cannot see. Validate the whole
Document to avoid that.
Returns:
| Type | Description |
|---|---|
list[Issue]
|
Every finding, errors first, then in tree order. An empty list means |
list[Issue]
|
nothing was found -- it is not a guarantee the layout opens. |
Source code in src/py2tosc/validate.py
Issue
dataclass
¶
One finding from validate.
Attributes:
| Name | Type | Description |
|---|---|---|
level |
str
|
|
path |
str
|
Slash-separated control names from the root, for locating it. |
message |
str
|
What is wrong. |
Source code in src/py2tosc/validate.py
ValidationError, raised by save(validate=True), is documented with the rest
of the errors.