Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.126s · 21.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.5s · import 1.082s · 22MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
email
✓ from validator_collection.validators import email
url
✓ from validator_collection.validators import url
is_email
✓ from validator_collection.checkers import is_email
is_url
✓ from validator_collection.checkers import is_url
validators
✓ from validator_collection import validators
Allows access to all validator functions via 'validators.function_name()'
checkers
✓ from validator_collection import checkers
Allows access to all checker functions via 'checkers.is_function_name()'
This quickstart demonstrates the two primary ways to use `validator-collection`: 'validator' functions which return the validated data or raise an error, and 'checker' functions which return a boolean indicating validity.
from validator_collection.validators import email, url
from validator_collection.checkers import is_email, is_url
# Example 1: Using validators (raise ValueError/TypeError if invalid)
try:
valid_email = email("test@example.com")
print(f"Validated Email: {valid_email}")
valid_url = url("https://www.example.com")
print(f"Validated URL: {valid_url}")
# This will raise a ValueError
# invalid_email = email("invalid-email")
# This will raise a ValueError
# invalid_url = url("not-a-url")
except (ValueError, TypeError) as e:
print(f"Validation Error: {e}")
# Example 2: Using checkers (return True/False)
print(f"Is 'test@example.com' a valid email? {is_email('test@example.com')}")
print(f"Is 'not-an-email' a valid email? {is_email('not-an-email')}")
print(f"Is 'https://example.com' a valid URL? {is_url('https://example.com')}")
print(f"Is 'ftp://another.com' a valid URL? {is_url('ftp://another.com')}") # Supports various protocols
Debug
Known issues
gotchaURL and domain validation logic has undergone frequent fixes and changes across minor versions (e.g., 1.3.3, 1.3.5, 1.4.1, 1.4.2, 1.5.0). This means the validation behavior for specific URLs might change after updating the library, potentially causing previously accepted (or rejected) inputs to now yield different results.fixThoroughly re-test any existing URL or domain validation logic after upgrading to a new minor or patch version, especially for edge cases or non-standard URLs.
affects: All versions prior to 1.5.0
deprecatedThe library officially supports Python 2.7, a version that has reached its end-of-life and is no longer maintained. While the library might function, continued use on Python 2.7 is highly discouraged due to security vulnerabilities and lack of future support.fixMigrate your application to a supported Python 3.x version (the library explicitly excludes Python 3.0-3.3, so aim for 3.4+).
affects: Users running Python 2.7
gotchaThe library provides two distinct patterns for validation: `validators.function()` which returns the validated value or raises `ValueError`/`TypeError`, and `checkers.is_function()` which returns a boolean. Mixing these up can lead to unexpected behavior or incorrect error handling in your application logic.fixAlways be explicit about whether you need to retrieve a validated value (use `validators`) or simply check for validity (use `checkers`). Implement `try-except` blocks for `validators` functions.
affects: All versions
gotchaThe project's release cadence has shown variability, with significant gaps between some minor versions (e.g., between 2020 and 2023 for 1.5.0). While still maintained, this might imply a slower pace for bug fixes or new feature development compared to other libraries.fixWhen integrating `validator-collection`, factor in the release history and set appropriate expectations for rapid support or feature additions.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'validator_collection.is_email'
The user is attempting to import a specific validator function (like `is_email`) directly from the top-level `validator_collection` package, but these functions reside within the `validators` or `checkers` submodules.
fixImport the function from the `validators` or `checkers` submodule, e.g., `from validator_collection.validators import is_email`.
AttributeError: module 'validator_collection.validators' has no attribute 'validate_email'
The user is attempting to call a validator function with an incorrect name (e.g., `validate_email`) that does not exist within the `validators` submodule. The correct function name for email validation is `is_email`.
fixUse the correct function name provided by the library, e.g., `from validator_collection import validators; email = validators.is_email('test@example.com')`. TypeError: is_email() missing 1 required positional argument: 'value'
A validator function (like `is_email`) was called without its mandatory `value` argument, which is the data intended for validation.
fixProvide the value to be validated as the first argument to the function, e.g., `from validator_collection import validators; email = validators.is_email('info@example.com')`. AttributeError: module 'validator_collection' has no attribute 'is_email'
The user imported the top-level `validator_collection` package but then tried to access a specific validator function directly from it. Validator functions are located within the `validators` or `checkers` submodules.
fixAccess the function through its submodule (e.g., `validator_collection.validators.is_email`) or import the specific function directly from its submodule (e.g., `from validator_collection.validators import is_email`).
Upgrade
Version history
1.5.0latest on PyPI · released Oct 12, 2020
Audit
Dependencies
No dependency data recorded yet.