{"id":5549,"library":"validator-collection","title":"validator-collection","description":"validator-collection is a Python library offering a comprehensive suite of over 60 functions for data validation and type checking. It provides both 'validator' functions that return the validated value or raise an error, and 'checker' functions that return a boolean. The current version is 1.5.0, with releases occurring periodically, sometimes with significant gaps between minor versions.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/insightindustry/validator-collection/","tags":["validation","data validation","checkers","validators","data types"],"install":[{"cmd":"pip install validator-collection","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"email","correct":"from validator_collection.validators import email"},{"symbol":"url","correct":"from validator_collection.validators import url"},{"symbol":"is_email","correct":"from validator_collection.checkers import is_email"},{"symbol":"is_url","correct":"from validator_collection.checkers import is_url"},{"note":"Allows access to all validator functions via 'validators.function_name()'","symbol":"validators","correct":"from validator_collection import validators"},{"note":"Allows access to all checker functions via 'checkers.is_function_name()'","symbol":"checkers","correct":"from validator_collection import checkers"}],"quickstart":{"code":"from validator_collection.validators import email, url\nfrom validator_collection.checkers import is_email, is_url\n\n# Example 1: Using validators (raise ValueError/TypeError if invalid)\ntry:\n    valid_email = email(\"test@example.com\")\n    print(f\"Validated Email: {valid_email}\")\n\n    valid_url = url(\"https://www.example.com\")\n    print(f\"Validated URL: {valid_url}\")\n\n    # This will raise a ValueError\n    # invalid_email = email(\"invalid-email\")\n\n    # This will raise a ValueError\n    # invalid_url = url(\"not-a-url\")\n\nexcept (ValueError, TypeError) as e:\n    print(f\"Validation Error: {e}\")\n\n# Example 2: Using checkers (return True/False)\nprint(f\"Is 'test@example.com' a valid email? {is_email('test@example.com')}\")\nprint(f\"Is 'not-an-email' a valid email? {is_email('not-an-email')}\")\nprint(f\"Is 'https://example.com' a valid URL? {is_url('https://example.com')}\")\nprint(f\"Is 'ftp://another.com' a valid URL? {is_url('ftp://another.com')}\") # Supports various protocols","lang":"python","description":"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."},"warnings":[{"fix":"Thoroughly 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.","message":"URL 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.","severity":"gotcha","affected_versions":"All versions prior to 1.5.0"},{"fix":"Migrate your application to a supported Python 3.x version (the library explicitly excludes Python 3.0-3.3, so aim for 3.4+).","message":"The 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.","severity":"deprecated","affected_versions":"Users running Python 2.7"},{"fix":"Always 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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"When integrating `validator-collection`, factor in the release history and set appropriate expectations for rapid support or feature additions.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}