示例#1
0
def URLValidator(value, **kwargs):
    from sentry.http import is_valid_url  # Django 1.9 setup issue
    if not value.startswith(('http://', 'https://')):
        raise PluginError('Not a valid URL.')
    if not is_valid_url(value):
        raise PluginError('Not a valid URL.')
    return value
示例#2
0
def validate_urls(value, **kwargs):
    from sentry.http import is_valid_url  # Django 1.9 setup issue
    urls = split_urls(value)
    if any((not u.startswith(('http://', 'https://')) or not is_valid_url(u))
           for u in urls):
        raise PluginError('Not a valid URL.')
    return '\n'.join(urls)
示例#3
0
def validate_urls4(value, **kwargs):
    output = []
    for url in value.split("\n"):
        url = url.strip()
        if not url:
            continue
        if not url.startswith(("http://", "https://")):
            raise PluginError("Not a valid URL.")
        if not is_valid_url(url):
            raise PluginError("Not a valid URL.")
        output.append(url)
    return "\n".join(output)
示例#4
0
def validate_urls(value, **kwargs):
    output = []
    for url in value.split('\n'):
        url = url.strip()
        if not url:
            continue
        if not url.startswith(('http://', 'https://')):
            raise PluginError('Not a valid URL.')
        if not is_valid_url(url):
            raise PluginError('Not a valid URL.')
        output.append(url)
    return '\n'.join(output)
示例#5
0
 def clean_url(self):
     value = self.cleaned_data.get('url')
     if not is_valid_url(value):
         raise forms.ValidationError('Invalid hostname')
     return value
示例#6
0
def validate_urls(value, **kwargs):
    urls = split_urls(value)
    if any((not u.startswith(("http://", "https://")) or not is_valid_url(u))
           for u in urls):
        raise PluginError("Not a valid URL.")
    return "\n".join(urls)
示例#7
0
 def clean_url(self):
     value = self.cleaned_data.get('url')
     if not is_valid_url(value):
         raise forms.ValidationError('Invalid hostname')
     return value
示例#8
0
def validate_urls(value, **kwargs):
    urls = split_urls(value)
    if any((not u.startswith(('http://', 'https://')) or not is_valid_url(u))
           for u in urls):
        raise PluginError('Not a valid URL.')
    return '\n'.join(urls)
示例#9
0
def validate_urls(value, **kwargs):
    urls = split_urls(value)
    if any((not u.startswith(('http://', 'https://')) or not is_valid_url(u)) for u in urls):
        raise PluginError('Not a valid URL.')
    return '\n'.join(urls)
def URLValidator(value, **kwargs):
    if not value.startswith(('http://', 'https://')):
        raise PluginError('Not a valid URL.')
    if not is_valid_url(value):
        raise PluginError('Not a valid URL.')
    return value
示例#11
0
def validate_url(url, **kwargs):
    if (not url.startswith(("http://", "https://")) or not is_valid_url(url)):
        raise PluginError("The {} is not a valid URL.".format(url))
    return url
示例#12
0
def URLValidator(value, **kwargs):
    if not value.startswith(("http://", "https://")):
        raise PluginError("Not a valid URL.")
    if not is_valid_url(value):
        raise PluginError("Not a valid URL.")
    return value