Command Argument Validators

Decorators to provide argument validation to a Tango command.

validate_json_args(*, schema: str | dict[str, JSONData] | None = None) Callable[[Callable[[...], Any]], Callable[[Any, str], Any]][source]
validate_json_args(command_method: Callable[[...], Any], *, schema: str | dict[str, JSONData] | None = None) Callable[[Any, str], Any]

Decorate a Tango command to take a validated JSON string as its single argument.

This decorator takes a function with a collection of keyword arguments and converts it into a function which takes a single string argument. The string argument is decoded as JSON and validated against an optional schema. The resulting dictionary’s key-value pairs matches the original function’s keyword arguments.

Only one of the optional keyword parameters for a schema can be used:

Parameters:
  • schema – Provide a JSON schema (dict) to validate the input JSON string against. Optional keyword.

  • schema_name – Provide a name (str) of a JSON schema object to access in the parent class (Tango device). Optional keyword.