validates host and/or ip.

@throws RuntimeException is domain is not valid
341454
public function validate($host = null, $ip = null)
    {
        $this->validHost($host);
        $this->validIp($ip);
    }
1012610
void doMain(String[] args, boolean throwOnError) throws Exception {
		if (args.length == 0) {
			usage(throwOnError, "no arguments specified");
			return;
		} else if (args.length > 2) {
			usage(throwOnError, "improper number of arguments:" + Arrays.toString(args));
			return;
		}

		// check for --usage or --help
		if (args.length == 1 && ("--usage".equals(args[0]) || "--help".equals(args[0]))) {
			usage(throwOnError, null);
			return;
		}

		CommandLineJmxClient jmxClient;
		if (args[0].indexOf('/') >= 0) {
			jmxClient = new CommandLineJmxClient(args[0]);
		} else {
			String[] parts = args[0].split(":");
			if (parts.length != 2) {
				usage(throwOnError, "argument should be in 'hostname:port' format, not: " + args[0]);
				return;
			}
			String hostName = parts[0];
			int port = 0;
			try {
				port = Integer.parseInt(parts[1]);
			} catch (NumberFormatException e) {
				usage(throwOnError, "port number not in the right format: " + parts[1]);
				return;
			}
			jmxClient = new CommandLineJmxClient(hostName, port);
		}

		if (args.length == 1) {
			jmxClient.runCommandLine();
		} else if (args.length == 2) {
			jmxClient.runBatchFile(new File(args[1]));
		}
	}
81917
public function validate()
    {
        if (!$this->migrationsDatabaseName) {
            $message = 'Migrations Database Name must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsNamespace) {
            $message = 'Migrations namespace must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
        if (!$this->migrationsDirectory) {
            $message = 'Migrations directory must be configured in order to use AntiMattr migrations.';
            throw new ConfigurationValidationException($message);
        }
    }
1171977
private function validate()
    {
        if (!$this->testServer($this->ssh, sprintf('-d "%s"', $this->directory))) {
            throw new SshValidateException('Directory does not exists');
        }

        if (!$this->testServer($this->ssh, sprintf('-x "%s"', $this->executable), $this->directory)) {
            throw new SshValidateException('Executable does not exists');
        }

        return true;
    }
847750
public function isValidDomain()
    {
        $domain = isset($_SERVER[ 'HTTP_HOST' ])
            ? $_SERVER[ 'HTTP_HOST' ]
            : $_SERVER[ 'SERVER_NAME' ];

        if ($this->domain === $domain) {
            return true;
        }

        return false;
    }
705910
protected void validate(String operationType) throws Exception
	{
		super.validate(operationType);

		MPSString name_validator = new MPSString();
		name_validator.validate(operationType, name, "\"name\"");
		
		MPSIPAddress host_ip_address_validator = new MPSIPAddress();
		host_ip_address_validator.validate(operationType, host_ip_address, "\"host_ip_address\"");
		
		MPSString current_value_validator = new MPSString();
		current_value_validator.validate(operationType, current_value, "\"current_value\"");
		
		MPSString expected_value_validator = new MPSString();
		expected_value_validator.validate(operationType, expected_value, "\"expected_value\"");
		
		MPSString unit_validator = new MPSString();
		unit_validator.validate(operationType, unit, "\"unit\"");
		
		MPSString status_validator = new MPSString();
		status_validator.validate(operationType, status, "\"status\"");
		
	}
426364
def _validate_domains(domains):
        """"""
        missing = set(settings.TRANSLATION_DOMAINS.keys()) - set(domains.keys())
        if missing:
            print('The following domains have been set in the configuration, '
                  'but their sources were not provided, use the `--source` '
                  'option to specify their sources: {domains}'.format(domains=', '.join(missing)))
            sys.exit(1)
579819
@Override
    public void basicValidate(final String section) throws ConfigException {
        if (StringUtils.isEmpty(host) || port == null || port <= 0 || port > MAX_PORT) {
            throw new ConfigException(section, "Invalid host and port");
        }
    }
1112372
private boolean validateServer(String host, int port){
        if(host==null || host.isEmpty()){
            return false;
        }
        if(port <=0 || port > 65535){
            return false;
        }
        return true;
    }
1065428
private void validate() {
        List<String> missingElements = new LinkedList<>();
        if (host == null) {
            missingElements.add("host");
        }

        if (protocol != null
            && !protocol.equalsIgnoreCase("noop")
            && !protocol.equalsIgnoreCase("out")) {

            if (publicKey == null) {
                missingElements.add("public key");
            }
            if (projectId == null || projectId.isEmpty()) {
                missingElements.add("project ID");
            }
        }

        if (!missingElements.isEmpty()) {
            throw new InvalidDsnException("Invalid DSN, the following properties aren't set '" + missingElements + "'");
        }
    }
1336613
public function domainAction()
    {
        $request = $this->getRequest();
        $type    = $request->getParam( 'type' );
        $domain  = $request->getParam( 'domain' );

        if ( ! $request instanceof ConsoleRequest )
        {
            throw new \RuntimeException( sprintf(
                '%s can only be used from a console.',
                __METHOD__
            ) );
        }

        $siteInfo = $this->getServiceLocator()
                         ->get( 'SiteInfo' );

        if ( $domain != $siteInfo->getDomain() )
        {
            throw new \RuntimeException( sprintf(
                '%s: domain mismatch. Detected "%s", while enforced "%s".',
                __METHOD__,
                $siteInfo->getDomain(),
                $domain
            ) );
        }

        $locator    = $this->getServiceLocator();
        $config     = $locator->get( 'Configuration' );

        if ( empty( $config['modules']['Grid\Core']['cron'] ) )
        {
            return '';
        }

        $result     = '';
        $keys       = array( 'site' );
        $cronConfig = $config['modules']['Grid\Core']['cron'];
        $modules    = $locator->get( 'Zend\ModuleManager\ModuleManagerInterface' )
                              ->getModules();

        if ( ! in_array( 'Grid\MultisitePlatform', $modules ) ||
               in_array( 'Grid\MultisiteCentral',  $modules ) )
        {
            $keys[] = 'once';
        }

        foreach ( $keys as $key )
        {
            if ( ! empty( $cronConfig[$key][$type] ) )
            {
                foreach ( $cronConfig[$key][$type] as $service )
                {
                    if ( is_scalar( $service ) )
                    {
                        $service = array(
                            'service' => $service,
                        );
                    }

                    if ( ! empty( $service['service'] ) )
                    {
                        $return = call_user_func_array(
                            array(
                                $this->getServiceLocator()
                                     ->get( $service['service'] ),
                                empty( $service['method'] )
                                    ? '__invoke'
                                    : (string) $service['method']
                            ),
                            empty( $service['arguments'] )
                                ? array()
                                : (array) $service['arguments']
                        );

                        $result .= sprintf(
                            'Service "%s" / %s / %s ',
                            $service['service'],
                            $key,
                            $type
                        );

                        if ( ! empty( $service['method'] ) )
                        {
                            $result .= sprintf( 'called "%s" ', $service['method'] );
                        }

                        if ( ! empty( $service['arguments'] ) )
                        {
                            $result .= Debug::dump(
                                $service['arguments'],
                                'with',
                                false
                            );
                        }

                        $result .= Debug::dump( $return, 'returned', false );
                    }
                }
            }
        }

        return $result;
    }
1035513
def validate(self, value):
        """"""
        try:
            self._choice = IPAddress(value)
            return True
        except (ValueError, AddrFormatError):
            self.error_message = '%s is not a valid IP address.' % value
            return False
29864
@Override
	public void validate() throws AddressStringException {
		if(isValidated()) {
			return;
		}
		synchronized(this) {
			if(isValidated()) {
				return;
			}
			//we know nothing about this address.  See what it is.
			try {
				parsedAddress = getValidator().validateAddress(this);
				isValid = true;
			} catch(AddressStringException e) {
				cachedException = e;
				isValid = false;
				throw e;
			}
		}
	}
677450
private function validate()
    {
        if (!class_exists($this->class)) {
            throw new \RuntimeException(sprintf('Class %s does not exist, is this the correct namespace?', $this->class));
        }
        if (!in_array($this->method, get_class_methods($this->class))) {
            throw new \RuntimeException(sprintf('The method "%s" does not exist in "%s" class.', $this->method, $this->class));
        }
    }
975319
private boolean netscapeDomainMatches(final String domain, final String host) {
        if (domain == null || host == null) {
            return false;
        }

        // if there's no embedded dot in domain and domain is not .local
        boolean isLocalDomain = ".local".equalsIgnoreCase(domain);
        int embeddedDotInDomain = domain.indexOf('.');
        if (embeddedDotInDomain == 0) {
            embeddedDotInDomain = domain.indexOf('.', 1);
        }
        if (!isLocalDomain && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1)) {
            return false;
        }

        // if the host name contains no dot and the domain name is .local
        int firstDotInHost = host.indexOf('.');
        if (firstDotInHost == -1 && isLocalDomain) {
            return true;
        }

        int domainLength = domain.length();
        int lengthDiff = host.length() - domainLength;
        if (lengthDiff == 0) {
            // if the host name and the domain name are just string-compare euqal
            return host.equalsIgnoreCase(domain);
        }
        else if (lengthDiff > 0) {
            // need to check H & D component
            String H = host.substring(0, lengthDiff);
            String D = host.substring(lengthDiff);

            return (D.equalsIgnoreCase(domain));
        }
        else if (lengthDiff == -1) {
            // if domain is actually .host
            return (domain.charAt(0) == '.' &&
                    host.equalsIgnoreCase(domain.substring(1)));
        }

        return false;
    }
500507
def validate_host_ip(ips, subnets):
    
    # Make sure we prune ``None`` arguments
    subnets = [s for s in subnets if s is not None]
    validate_one_subnet = len(subnets) == 1

    def ip_in_one_subnet(ips, subnet):
        """ ensure an ip exists in at least one subnet """
        for ip in ips:
            if net.ip_in_subnet(ip, subnet):
                return True
        return False

    for subnet in subnets:
        if ip_in_one_subnet(ips, subnet):
            if validate_one_subnet:
                return
            else:  # keep going to make sure the other subnets are ok
                continue
        else:
            msg = "subnet (%s) is not valid for any of the ips found %s" % (subnet, str(ips))
            raise RuntimeError(msg)
936482
private void validateNode() throws InvalidQueryNodeException {
        ImmutableSet<Variable> substitutionDomain = substitution.getDomain();

        // The substitution domain must be a subset of the projectedVariables
        if (!projectedVariables.containsAll(substitutionDomain)) {
            throw new InvalidQueryNodeException("ConstructionNode: all the domain variables " +
                    "of the substitution must be projected.\n" + toString());
        }

        // The variables contained in the domain and in the range of the substitution must be disjoint
        if (substitutionDomain.stream()
                .anyMatch(childVariables::contains)) {
            throw new InvalidQueryNodeException("ConstructionNode: variables defined by the substitution cannot " +
                    "be used for defining other variables.\n" + toString());
        }

        // Substitution to non-projected variables is incorrect
        if (substitution.getImmutableMap().values().stream()
                .filter(v -> v instanceof Variable)
                .map(v -> (Variable) v)
                .anyMatch(v -> !projectedVariables.contains(v))) {
            throw new InvalidQueryNodeException(
                    "ConstructionNode: substituting a variable " +
                            "by a non-projected variable is incorrect.\n"
                + toString());
        }
    }