This topic discusses the parameter validation feature provided by the PLANTA link API.


For each parameter you register in a mapping function or module subclass you can specify a parameter validator that ensures that the parameter has a valid value.

The user will be prevented from entering invalid data on the GUI, the functions that change a parameter won't let you change it to a illegal value and the sanity check for a configuration will fail when a parameter validator fails its check.

Classes

ParameterValidator

Base class for all parameter validator implementations

Methods

FunctionParametersReturn ValueDescription
ParameterValidator._init_(self, parameter_name)parameter_name: Name
Initialize a ParameterValidator
ParameterValidator.get_error_message(self, value)value: String valueError message as stringOverride this in a subclass and provide a meaningful error message to the user
ParameterValidator.validate(self, value)value: String valueTrue or FalseOverride this in a subclass and implement a validation that returns True or False

Properties

PropertyGetterSetterDescription
ParameterValidator.parameter_nameThe Name this class was initialized with

BoolValidator

Validator for parameters that can only be 0 or 1.

EncodingValidator

Validator for parameters that must be a valid file encoding name.

ListValidator

Validator for parameters that have a specific list of valid values.

Requires an allowed_values  argument containing a list of valid values.

LengthValidator

Validator for parameters that have a specific minimum/maximum length.

Requires a min_length  and max_length  argument.

RegexValidator

Validator that matches parameters with a regular expression.

Requires a pattern  and flags  argument to pass to the regex engine.

DataAreaValidator

Validator for parameters that must contain a valid data area in a module.

Requires a module_id  and module_type  argument, with the module_type  being a value from the ppms.interface.ModuleType  enum.

DelimiterValidator

Validator for the CSVModule delimiter parameter.

IntegerValidator

Validator for parameters that must be integers.

TimeFormatValidator

Validator for parameters that must be a valid time format like %d.%m.%Y.

MandatoryValidator

Validator for parameters that must not be empty.

LengthWithExceptionsValidator

Validator for parameters that have a specific minimum/maximum length but also a set of special inputs outside that range which are also valid.

Requires a maximum_length  and exceptions  argument, with exceptions being a list of acceptable values.

ValidInterfaceValidator

Validator for parameters that must point to a valid interface configuration UUID.