sgr_commhandler.validators.validator

Provides data type validators.

Attributes

INT_SIZES

FLOAT_SIZES

Classes

UnsupportedValidator

Implements a default validator for all unsupported data types.

EnumValidator

Implements a validator for enumeration values.

IntValidator

Implements a validator for integer values.

FloatValidator

Implements a validator for floating-point values.

StringValidator

Implements a validator for text strings.

BooleanValidator

Implements a validator for boolean values.

BitmapValidator

Implements a validator for bitmap values.

DateTimeValidator

Implements a validator for date/time values.

JsonValidator

Implements a validator for JSON values.

Module Contents

sgr_commhandler.validators.validator.INT_SIZES: set[int]
sgr_commhandler.validators.validator.FLOAT_SIZES: set[int]
class sgr_commhandler.validators.validator.UnsupportedValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a default validator for all unsupported data types.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.EnumValidator(type)

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for enumeration values.

Parameters:

type (sgr_specification.v0.generic.EnumMapProduct)

_valid_literals: set[str]
_valid_ordinals: set[int]
validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

options()

Gets the validator’s options.

Returns:

the options

Return type:

list[Any]

class sgr_commhandler.validators.validator.IntValidator(size, signed=True)

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for integer values.

Parameters:
  • size (int)

  • signed (bool)

_size
validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.FloatValidator(size)

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for floating-point values.

Parameters:

size (int)

_size
validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.StringValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for text strings.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.BooleanValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for boolean values.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.BitmapValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for bitmap values.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.DateTimeValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for date/time values.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool

class sgr_commhandler.validators.validator.JsonValidator

Bases: sgr_commhandler.api.data_point_api.DataPointValidator

Implements a validator for JSON values.

validate(value)

Validates the compatibility of a value.

Parameters:

value (Any) – the value to validate

Returns:

true if value is compatible, false otherwise

Return type:

bool