Validators
Validation utilities for PyEyesWeb.
This module provides common validation functions used across multiple PyEyesWeb modules to ensure consistent error handling.
validate_and_normalize_filter_params(filter_params)
Validate and normalize filter parameters.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in pyeyesweb/utils/validators.py
validate_boolean(value, name)
Validate boolean parameter.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> validate_boolean(True, 'use_filter')
True
>>> validate_boolean(1, 'output_phase')
TypeError: output_phase must be boolean, got int
Source code in pyeyesweb/utils/validators.py
validate_filter_params_tuple(value, name='filter_params')
Validate filter parameters tuple structure.
Ensures the value is a tuple/list with exactly 3 numeric elements before passing to validate_filter_params for frequency validation.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> validate_filter_params_tuple((1.0, 10.0, 100.0))
(1.0, 10.0, 100.0)
>>> validate_filter_params_tuple([1, 10, 100])
(1, 10, 100)
>>> validate_filter_params_tuple("invalid")
TypeError: filter_params must be a tuple or list, got str
Source code in pyeyesweb/utils/validators.py
validate_integer(value, name, min_val=None, max_val=None)
Validate integer parameter with optional bounds checking.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> validate_integer(100, 'sensitivity', min_val=1, max_val=10000)
100
>>> validate_integer(0, 'max_length', min_val=1)
ValueError: max_length must be >= 1, got 0
Source code in pyeyesweb/utils/validators.py
validate_numeric(value, name, min_val=None, max_val=None)
Validate numeric parameter with optional bounds checking.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> validate_numeric(50.0, 'rate_hz', min_val=0.1, max_val=100000)
50.0
>>> validate_numeric(-1, 'phase', min_val=0, max_val=1)
ValueError: phase must be >= 0, got -1
Source code in pyeyesweb/utils/validators.py
validate_range(value, name, min_val, max_val)
Validate that a value is within a specific range.
Useful for parameters that must be within a specific range like phase_threshold (0-1), percentages (0-100), etc.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Examples:
>>> validate_range(0.7, 'phase_threshold', 0, 1)
0.7
>>> validate_range(1.5, 'probability', 0, 1)
ValueError: probability must be between 0 and 1, got 1.5
Source code in pyeyesweb/utils/validators.py
validate_window_size(value, name='window_size')
Validate window size parameter.
Standard validation for window sizes used across multiple modules.
| Parameters: |
|
|---|
| Returns: |
|
|---|