ccproxy.core.validators¶
ccproxy.core.validators
¶
Generic validation utilities for the CCProxy API.
validate_email
¶
Validate email format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email
|
str
|
Email address to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated email address |
Raises:
Type | Description |
---|---|
ValidationError
|
If email format is invalid |
Source code in ccproxy/core/validators.py
validate_url
¶
Validate URL format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
URL to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated URL |
Raises:
Type | Description |
---|---|
ValidationError
|
If URL format is invalid |
Source code in ccproxy/core/validators.py
validate_uuid
¶
Validate UUID format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uuid_str
|
str
|
UUID string to validate |
required |
Returns:
Type | Description |
---|---|
str
|
The validated UUID string |
Raises:
Type | Description |
---|---|
ValidationError
|
If UUID format is invalid |
Source code in ccproxy/core/validators.py
validate_path
¶
Validate file system path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str | Path
|
Path to validate |
required |
must_exist
|
bool
|
Whether the path must exist |
True
|
Returns:
Type | Description |
---|---|
Path
|
The validated Path object |
Raises:
Type | Description |
---|---|
ValidationError
|
If path is invalid |
Source code in ccproxy/core/validators.py
validate_port
¶
Validate port number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
port
|
int | str
|
Port number to validate |
required |
Returns:
Type | Description |
---|---|
int
|
The validated port number |
Raises:
Type | Description |
---|---|
ValidationError
|
If port is invalid |
Source code in ccproxy/core/validators.py
validate_timeout
¶
Validate timeout value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
timeout
|
float | int | str
|
Timeout value to validate |
required |
Returns:
Type | Description |
---|---|
float
|
The validated timeout value |
Raises:
Type | Description |
---|---|
ValidationError
|
If timeout is invalid |
Source code in ccproxy/core/validators.py
validate_non_empty_string
¶
Validate that a string is not empty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
String value to validate |
required |
name
|
str
|
Name of the field for error messages |
'value'
|
Returns:
Type | Description |
---|---|
str
|
The validated string |
Raises:
Type | Description |
---|---|
ValidationError
|
If string is empty or not a string |
Source code in ccproxy/core/validators.py
validate_dict
¶
Validate dictionary and required keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
Value to validate as dictionary |
required |
required_keys
|
list[str] | None
|
List of required keys |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any]
|
The validated dictionary |
Raises:
Type | Description |
---|---|
ValidationError
|
If not a dictionary or missing required keys |
Source code in ccproxy/core/validators.py
validate_list
¶
Validate list and length constraints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
Value to validate as list |
required |
min_length
|
int
|
Minimum list length |
0
|
max_length
|
int | None
|
Maximum list length |
None
|
Returns:
Type | Description |
---|---|
list[Any]
|
The validated list |
Raises:
Type | Description |
---|---|
ValidationError
|
If not a list or length constraints are violated |
Source code in ccproxy/core/validators.py
validate_choice
¶
Validate that value is one of the allowed choices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Any
|
Value to validate |
required |
choices
|
list[Any]
|
List of allowed choices |
required |
name
|
str
|
Name of the field for error messages |
'value'
|
Returns:
Type | Description |
---|---|
Any
|
The validated value |
Raises:
Type | Description |
---|---|
ValidationError
|
If value is not in choices |
Source code in ccproxy/core/validators.py
validate_range
¶
Validate that a numeric value is within a specified range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
float | int
|
Numeric value to validate |
required |
min_value
|
float | int | None
|
Minimum allowed value |
None
|
max_value
|
float | int | None
|
Maximum allowed value |
None
|
name
|
str
|
Name of the field for error messages |
'value'
|
Returns:
Type | Description |
---|---|
float | int
|
The validated value |
Raises:
Type | Description |
---|---|
ValidationError
|
If value is outside the allowed range |