How to use the validators.ValidationFailure function in validators

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 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 / 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)
github kvesteri / validators / tests / test_slug.py View on Github external
def test_returns_failed_validation_on_invalid_slug(value):
    assert isinstance(slug(value), ValidationFailure)
github kvesteri / validators / tests / test_ipv6.py View on Github external
def test_returns_failed_validation_on_invalid_ipv6_address(address):
    assert isinstance(ipv6(address), ValidationFailure)
github kvesteri / validators / tests / i18n / test_fi.py View on Github external
def test_returns_failed_validation_on_temporal_ssn_when_not_allowed():
    assert isinstance(
        fi_ssn('010190-900P', allow_temporal_ssn=False),
        ValidationFailure
    )
github Royal-Society-of-New-Zealand / NZ-ORCID-Hub / orcid_hub / authcontroller.py View on Github external
def content(data=None):
            s = Signer(app.secret_key)
            if data:
                sep = '\t' if '\t' in data else ','
                for line_no, line in enumerate(data.splitlines()):
                    values = [v.strip() for v in line.split(sep)]
                    for v in values:
                        if '@' in v:
                            try:
                                validators.email(v)
                                email = v
                                break
                            except validators.ValidationFailure:
                                pass
                    else:
                        if line_no == 0:
                            continue
                        flash("Missing email address in the file", "danger")
                        abort(400)
                    yield s.get_signature(email).decode() + sep + sep.join(values)
                    yield '\n'
            else:
                use_known_orgs = bool(
                    request.args.get("use-known-orgs") or form.use_known_orgs.data)
                org_count = int(
                    request.args.get("orgs") or request.args.get("org_count")
                    or request.args.get("org-count") or form.org_count.data or 100)
                user_count = int(
                    request.args.get("users") or request.args.get("user_count")
github pyload / pyload-webui / pyload / utils / web / check.py View on Github external
def isurl(url):
    url = format.url(url)
    try:
        return validators.url(url)
    except validators.ValidationFailure:
        return False