Validator Utilities
has_special_chars(val, mode='LOW')
Check if the string has special characters. Available modes: - "BASE" or "HTML": Basic HTML special characters. - "LOW": Low-risk special characters. - "MEDIUM": Medium-risk special characters. - "HIGH", "SCRIPT", or "SQL": High-risk special characters. - "STRICT": Strict mode, checks for most special characters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str, required)
|
String to check. |
required |
mode
|
str
|
Check mode. Defaults to "LOW". |
'LOW'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the string has special characters, False otherwise. |
Source code in src/potato_util/validator.py
is_blacklisted(val, blacklist)
Check if the string is blacklisted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str, required)
|
String to check. |
required |
blacklist
|
(List[str], required)
|
List of blacklisted strings. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the string is blacklisted, False otherwise. |
Source code in src/potato_util/validator.py
is_falsy(val)
Check if the value is falsy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str | bool | int | float | None, required)
|
Value to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is falsy, False otherwise. |
Source code in src/potato_util/validator.py
is_request_id(val)
Check if the string is valid request ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str, required)
|
String to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the string is valid request ID, False otherwise. |
Source code in src/potato_util/validator.py
is_truthy(val)
Check if the value is truthy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str | bool | int | float | None, required)
|
Value to check. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the value is truthy, False otherwise. |
Source code in src/potato_util/validator.py
is_valid(val, pattern)
Check if the string is valid with given pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
(str, required)
|
String to check. |
required |
pattern
|
(Pattern | str, required)
|
Pattern regex to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the string is valid with given pattern, False otherwise. |