How to use validators - 10 common examples

To help you get started, we’ve selected a few validators examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Morgan-Stanley / testplan / testplan / common / utils / validation.py View on Github external
def is_valid_url(url):
    """Validator that checks if a url is valid"""
    return bool(validators.url(url))
github kvesteri / validators / tests / test_domain.py View on Github external
def test_returns_true_on_valid_domain(value):
    assert domain(value)
github kvesteri / validators / tests / test_ipv4.py View on Github external
def test_returns_true_on_valid_ipv4_address(address):
    assert ipv4(address)
    assert not ipv6(address)
github ValyrianTech / BitcoinSpellbook / unittests / test_validators.py View on Github external
def test_valid_address_testnet(self, address, expected, description):
        helpers.configurationhelpers.get_use_testnet = mock.MagicMock(return_value=True)
        print(description)
        assert validators.valid_address(address) == expected, description
github kvesteri / validators / tests / test_uuid.py View on Github external
def test_returns_failed_validation_on_invalid_mac_address(value):
    assert isinstance(uuid(value), ValidationFailure)
github kvesteri / validators / tests / test_uuid.py View on Github external
def test_returns_true_on_valid_mac_address(value):
    assert uuid(value)
github kvesteri / validators / tests / i18n / test_fi.py View on Github external
def test_returns_failed_validation_on_invalid_email(value):
    assert isinstance(fi_business_id(value), ValidationFailure)
github kvesteri / validators / tests / test_length.py View on Github external
def test_returns_failed_validation_on_invalid_range(value, min, max):
    assert isinstance(
        validators.length(value, min=min, max=max),
        validators.ValidationFailure
    )
github kvesteri / validators / tests / test_between.py View on Github external
def test_returns_failed_validation_on_invalid_range(value, min, max):
    result = validators.between(value, min=min, max=max)
    assert isinstance(result, validators.ValidationFailure)
github kvesteri / validators / tests / test_url.py View on Github external
def test_returns_failed_validation_on_invalid_url(address):
    assert isinstance(url(address), ValidationFailure)