Validates a non-required URL value using IsValidURL():
    - if invalid adds InvalidValue error (if problems accumulator is provided)
    - an empty URL is considered valid and no error or warning is issued.
345658
def ValidateURL(url, column_name=None, problems=None):
  
  if IsEmpty(url) or IsValidURL(url):
    return True
  else:
    if problems:
      problems.InvalidValue(column_name, url)
    return False
385431
def check_url_does_not_exists(form, field):
    ''''''
    if field.data != field.object_data and Reuse.url_exists(field.data):
        raise validators.ValidationError(_('This URL is already registered'))
320404
private boolean checkUrl(String url) {
        try {
            URI uri = new URI(url);
            return uri.isAbsolute();
        } catch (URISyntaxException e) {
            return false;
        }
    }
349721
public void validate() {
    if (metric == null || metric.isEmpty()) {
      throw new IllegalArgumentException("missing or empty metric");
    }

    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("missing or empty id");
    }
    Query.validateId(id);

    if (time_offset != null) {
      DateTime.parseDateTimeString(time_offset, null);
    }
    
    if (aggregator != null && !aggregator.isEmpty()) {
      try {
        Aggregators.get(aggregator.toLowerCase());
      } catch (final NoSuchElementException e) {
        throw new IllegalArgumentException("Invalid aggregator");
      }
    }

    if (fill_policy != null) {
      fill_policy.validate();
    }
  }
111717
public boolean isValid() {
		if(parsedHost != null) {
			return true;
		}
		if(validationException != null) {
			return false;
		}
		try {
			validate();
			return true;
		} catch(HostNameException e) {
			return false;
		}
	}
553948
def valid(self, value, level=[]):
		

		# Reset validation failures
		self.validation_failures = []

		# If the value is None and it's optional, we're good
		if value is None and self._optional:
			return True

		# If the value isn't a dictionary
		if not isinstance(value, dict):
			self.validation_failures.append(('.'.join(level), str(value)))
			return False

		# Init the return, assume valid
		bRet = True

		# Go through each key and value
		for k,v in iteritems(value):

			# Add the field to the level
			lLevel = level[:]
			lLevel.append(k)

			# If the key isn't valid
			if not self._key.valid(k):
				self.validation_failures.append(('.'.join(lLevel), 'invalid key: %s' % str(k)))
				bRet = False
				continue

			# Check the value
			if not self._node.valid(v, lLevel):
				self.validation_failures.extend(self._node.validation_failures)
				bRet = False
				continue

		# Return whatever the result was
		return bRet
27474
def validate_urls(urls, allowed_response_codes=None):
    

    for url in urls:
        validate_url(url, allowed_response_codes=allowed_response_codes)
    return True
1101526
def valid_url(x: str) -> bool:
    
    if isinstance(x, str) and re.match(URL_PATTERN, x):
        return True
    else:
        return False
54982
def _IsValidUrl(self, url):
    
    parsed_url = urlparse.urlparse(url)
    return parsed_url.scheme in self._SUPPORTED_URL_SCHEMES
713012
protected void validate() {
    // make sure that the source uri is set correctly.
    if (mSourceUri == null) {
      throw new BuilderException("Source must be set!");
    }

    // For local resource we require caller to specify statically generated resource id as a path.
    if (UriUtil.isLocalResourceUri(mSourceUri)) {
      if (!mSourceUri.isAbsolute()) {
        throw new BuilderException("Resource URI path must be absolute.");
      }
      if (mSourceUri.getPath().isEmpty()) {
        throw new BuilderException("Resource URI must not be empty");
      }
      try {
        Integer.parseInt(mSourceUri.getPath().substring(1));
      } catch (NumberFormatException ignored) {
        throw new BuilderException("Resource URI path must be a resource id.");
      }
    }

    // For local asset we require caller to specify absolute path of an asset, which will be
    // resolved by AssetManager relative to configured asset folder of an app.
    if (UriUtil.isLocalAssetUri(mSourceUri) && !mSourceUri.isAbsolute()) {
      throw new BuilderException("Asset URI path must be absolute.");
    }
  }
301637
def validate(self, value):
        ''''''
        if not self.blank and value == '':
            self.error_message = 'Can not be empty.  Please provide a value.'
            return False
        self._choice = value
        return True
1285896
def validate(self, value):
        
        if self.required and not value:
            raise OAuthValidationError({'error': 'invalid_request'})

        # Validate that each value in the value list is in self.choices.
        for val in value:
            if not self.valid_value(val):
                raise OAuthValidationError({
                    'error': 'invalid_request',
                    'error_description': _("'%s' is not a valid scope.") % \
                            val})
1240679
public static boolean isValidEmail(Object value) {

	InternetAddress addr = parseEmail(value, null);

	if (addr != null) {

	    String address = addr.getAddress();

	    if (address.contains("..")) return false;

	    int pos = address.indexOf('@');

	    if (pos < 1 || pos == address.length() - 1) return false;

	    String local = address.substring(0, pos);
	    String domain = address.substring(pos + 1);

	    if (domain.charAt(0) == '.' || local.charAt(0) == '.' || local.charAt(local.length() - 1) == '.') return false;

	    pos = domain.lastIndexOf('.');

	    if (pos > 0 && pos < domain.length() - 2) { // test TLD to be at
							// least 2 chars all
							// alpha characters
		if (StringUtil.isAllAlpha(domain.substring(pos + 1))) return true;
		try {
		    addr.validate();
		    return true;
		}
		catch (AddressException e) {}
	    }
	}

	return false;
    }
846493
def validate(self, instance, value):
        """"""
        value = super(URL, self).validate(instance, value)
        parsed_url = urlparse(value)
        if not parsed_url.scheme or not parsed_url.netloc:
            self.error(instance, value, extra='URL needs scheme and netloc.')
        parse_result = ParseResult(
            scheme=parsed_url.scheme,
            netloc=parsed_url.netloc,
            path=parsed_url.path,
            params='' if self.remove_parameters else parsed_url.params,
            query='' if self.remove_parameters else parsed_url.query,
            fragment='' if self.remove_fragment else parsed_url.fragment,
        )
        parse_result = parse_result.geturl()
        return parse_result
200458
public function validateUrl($url)
    {
        if (empty($url)) {
            throw new \InvalidArgumentException('The field cannot be empty.');
        }

        if (!filter_var($url, FILTER_VALIDATE_URL)) {
            throw new \InvalidArgumentException('The field requires a valid URL.');
        }

        return $url;
    }
590661
def is_valid_url(value):
    
    match = URL_REGEX.match(value)
    host_str = urlparse(value).hostname
    return match and is_valid_host(host_str)
754933
def _parse_url_and_validate(cls, url):
        
        parsed_url = urlparse(url)
        if parsed_url.scheme and parsed_url.netloc:
            final_url = parsed_url.geturl()
        else:
            raise BadURLException
        return final_url