sec_interp.core.validation.field_validator module

Validation logic for QGIS layer fields and attributes.

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)
  • is_valid: True if validation passed.

  • error_message: Error details if validation failed.

Return type:

tuple

sec_interp.core.validation.field_validator.validate_field_exists(layer: qgis.core.QgsVectorLayer, field_name: str | None) tuple[bool, str]

Validate that a specific field exists in a vector layer.

Parameters:
  • layer – The QGIS vector layer to check.

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

Returns:

(is_valid, error_message)
  • is_valid: True if validation passed.

  • error_message: Error details if validation failed.

Return type:

tuple

sec_interp.core.validation.field_validator.validate_field_type(layer: qgis.core.QgsVectorLayer, 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:
  • layer – The QGIS vector layer containing the field.

  • field_name – The name of the field to check.

  • expected_types – List of allowed FieldType values.

Returns:

(is_valid, error_message)
  • is_valid: True if validation passed.

  • error_message: Error details if validation failed.

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)
  • is_valid: True if validation passed.

  • error_message: Error details if validation failed.

  • int_value: The parsed integer value if valid, else None.

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)
  • is_valid: True if validation passed.

  • error_message: Error details if validation failed.

  • float_value: The parsed numeric value if valid, else None.

Return type:

tuple