Exemple #1
0
 def __call__(self, form, field):
     if not is_valid_uri(
         field.data,
         require_authority=self.require_authority,
         allowed_schemes=self.allowed_schemes,
         require_scheme=self.require_scheme,
     ):
         raise ValidationError("Invalid URI")
Exemple #2
0
 def __call__(self, form, field):
     if not is_valid_uri(
         field.data,
         require_authority=self.require_authority,
         allowed_schemes=self.allowed_schemes,
         require_scheme=self.require_scheme,
     ):
         raise ValidationError("Invalid URI")
Exemple #3
0
def _validate_project_url(value):
    try:
        label, url = value.split(", ", 1)
    except ValueError:
        raise wtforms.validators.ValidationError(
            "Use both a label and an URL.") from None

    if not label:
        raise wtforms.validators.ValidationError("Use a label.")

    if len(label) > 32:
        raise wtforms.validators.ValidationError("Use 32 characters or less.")

    if not url:
        raise wtforms.validators.ValidationError("Use an URL.")

    if not http.is_valid_uri(url, require_authority=False):
        raise wtforms.validators.ValidationError("Use valid URL.")
Exemple #4
0
def _validate_project_url(value):
    try:
        label, url = value.split(", ", 1)
    except ValueError:
        raise wtforms.validators.ValidationError(
            "Must have both a label and an URL.", ) from None

    if not label:
        raise wtforms.validators.ValidationError("Must have a label.")

    if len(label) > 32:
        raise wtforms.validators.ValidationError(
            "Label must not be longer than 32 characters.")

    if not url:
        raise wtforms.validators.ValidationError("Must have an URL.")

    if not http.is_valid_uri(url, require_authority=False):
        raise wtforms.validators.ValidationError("Invalid URL.")
Exemple #5
0
def _validate_project_url(value):
    try:
        label, url = value.split(", ", 1)
    except ValueError:
        raise wtforms.validators.ValidationError(
            "Use both a label and an URL."
        ) from None

    if not label:
        raise wtforms.validators.ValidationError("Use a label.")

    if len(label) > 32:
        raise wtforms.validators.ValidationError("Use 32 characters or less.")

    if not url:
        raise wtforms.validators.ValidationError("Use an URL.")

    if not http.is_valid_uri(url, require_authority=False):
        raise wtforms.validators.ValidationError("Use valid URL.")
Exemple #6
0
def _validate_project_url(value):
    try:
        label, url = value.split(", ", 1)
    except ValueError:
        raise wtforms.validators.ValidationError(
            "Must have both a label and an URL.",
        ) from None

    if not label:
        raise wtforms.validators.ValidationError("Must have a label.")

    if len(label) > 32:
        raise wtforms.validators.ValidationError(
            "Label must not be longer than 32 characters."
        )

    if not url:
        raise wtforms.validators.ValidationError("Must have an URL.")

    if not http.is_valid_uri(url, require_authority=False):
        raise wtforms.validators.ValidationError("Invalid URL.")
Exemple #7
0
 def test_invalid(self, uri):
     assert not is_valid_uri(uri)
Exemple #8
0
 def test_valid(self, uri):
     assert is_valid_uri(uri)
Exemple #9
0
def contains_valid_uris(items):
    """Returns boolean representing whether the input list contains any valid
    URIs
    """
    return any(is_valid_uri(i) for i in items)
Exemple #10
0
 def test_authority_not_required(self):
     assert is_valid_uri("http://", require_authority=False)
Exemple #11
0
 def test_scheme_not_required(self):
     assert is_valid_uri("//example.com", require_scheme=False)
Exemple #12
0
 def test_plain_schemes(self):
     assert is_valid_uri("ftp://example.com/", require_scheme=True,
                         allowed_schemes=[])
Exemple #13
0
 def test_invalid(self, uri):
     assert not is_valid_uri(uri)
Exemple #14
0
 def test_valid(self, uri):
     assert is_valid_uri(uri)
Exemple #15
0
 def test_authority_not_required(self):
     assert is_valid_uri("http://", require_authority=False)
Exemple #16
0
 def test_plain_schemes(self):
     assert is_valid_uri("ftp://example.com/", require_scheme=True,
                         allowed_schemes=[])
Exemple #17
0
 def test_scheme_not_required(self):
     assert is_valid_uri("//example.com", require_scheme=False)
Exemple #18
0
def contains_valid_uris(items):
    """Returns boolean representing whether the input list contains any valid
    URIs
    """
    return any(is_valid_uri(i) for i in items)