Command Argument Validators

Decorators to provide argument validation to a Tango command.

ska_tango_base.validators.validate_json_args(*, schema: str | dict[str, JSONData] | None = None) Callable[[Callable[[...], Any]], Callable[[Any, str], Any]][source]
ska_tango_base.validators.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.

For long running commands this decorator must always be applied first (innermost) to allow the LRC to catch validation errors and reject the task.

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.

Raises:

ValidateJSONArgsError – If either the JSON schema cannot be found, the given command arg is not valid JSON or a JSON dict, or it failed schema validation.