Validation
When to validate
Describe shapes with @definition_schema
@definition_schemafrom spx_sdk.components import SpxComponent
from spx_sdk.validation.decorators import definition_schema
@definition_schema({
"type": "object",
"properties": {
"name": {"type": "string"},
"safe_range": {
"type": "object",
"properties": {
"min": {"type": "number"},
"max": {"type": "number"},
},
"required": ["min", "max"],
"additionalProperties": False,
},
"sensors": {
"type": "object",
"x-spx-children-of": "BaseSensor", # expect registered subclasses
},
},
"required": ["name", "safe_range"],
"additionalProperties": False,
})
class MixerModule(SpxComponent):
...Add custom rules with @definition_validator
@definition_validatorRun validation programmatically
Validate entire documents
Reporting results back to clients
Typical workflow
Last updated

