sec_interp.core.validation.field_validator module

Validation logic for layer fields and attributes (QGIS-agnostic).

sec_interp.core.validation.field_validator.validate_angle_range(value: float, field_name: str, min_angle: float = 0.0, max_angle: float = 360.0) → tuple[bool, str]

Validate that an angle value is within the expected range.

Parameters:
  • value – The angle value to validate.

  • field_name – Name of the field for error messages.

  • min_angle – Minimum allowed angle (default 0.0).

  • max_angle – Maximum allowed angle (default 360.0).

Returns:

(is_valid, error_message)

Return type:

tuple

sec_interp.core.validation.field_validator.validate_field_exists(metadata: LayerMetadata, field_name: str | None) → tuple[bool, str]

Validate that a specific field exists in a layer.

Parameters:
  • metadata – The detached layer metadata.

  • field_name – The name of the field to search for.

Returns:

(is_valid, error_message)

Return type:

tuple

sec_interp.core.validation.field_validator.validate_field_type(metadata: LayerMetadata, field_name: str, expected_types: list[FieldType]) → tuple[bool, str]

Validate that a field in a layer has one of the expected data types.

Parameters:
  • metadata – The detached layer metadata.

  • field_name – The name of the field to check.

  • expected_types – List of allowed FieldType values.

Returns:

(is_valid, error_message)

Return type:

tuple

sec_interp.core.validation.field_validator.validate_integer_input(value: str, min_val: int | None = None, max_val: int | None = None, field_name: str = 'Value', allow_empty: bool = False) → tuple[bool, str, int | None]

Validate an integer input string from a text field.

Parameters:
  • value – The string value to validate.

  • min_val – Optional minimum value allowed.

  • max_val – Optional maximum value allowed.

  • field_name – Name of the field for error messages.

  • allow_empty – Whether to allow an empty string.

Returns:

(is_valid, error_message, int_value)

Return type:

tuple

sec_interp.core.validation.field_validator.validate_numeric_input(value: str, min_val: float | None = None, max_val: float | None = None, field_name: str = 'Value', allow_empty: bool = False) → tuple[bool, str, float | None]

Validate a numeric input string from a text field.

Parameters:
  • value – The string value to validate.

  • min_val – Optional minimum value allowed.

  • max_val – Optional maximum value allowed.

  • field_name – Name of the field for error messages.

  • allow_empty – Whether to allow an empty string.

Returns:

(is_valid, error_message, float_value)

Return type:

tuple