helakit.phone
helakit.phone
Sri Lankan phone-number validation.
Typical usage::
import helakit as hk
result = hk.validate_phone("0712345678")
result.normalized # "+94712345678"
result.data # PhoneDecoded(carrier="Mobitel", line_type="mobile", local="0712345678")
hk.is_valid_phone("+94762345678") # True
PhoneDecoded
dataclass
PhoneDecoded(carrier: str, line_type: LineType, local: str)
Structured metadata returned in ValidationResult.data["decoded"].
PhoneError
Bases: HelakitError
Raised for unrecoverable phone-related programmer errors.
is_valid_phone
is_valid_phone(value: str) -> bool
Return True if value is a valid Sri Lankan phone number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The phone number to check (local or international form). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
If |
validate_phone
validate_phone(value: str) -> ValidationResult
Validate a Sri Lankan phone number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The phone number in local ( |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
ValidationResult
|
class: |
ValidationResult
|
|
|
ValidationResult
|
|
|
ValidationResult
|
|
|
ValidationResult
|
|
|
ValidationResult
|
|
|
ValidationResult
|
|
Raises:
| Type | Description |
|---|---|
InvalidInputError
|
If |