Validate the CLIENT subcommands.
967714
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var sub = info.command.sub
    , cmd = ('' + sub.cmd)
    , args = sub.args
    , timeout
    , conn;

  if(cmd === Constants.SUBCOMMAND.client.pause.name) {
    timeout = parseInt('' + args[0]);
    // redis returns: 'timeout is' ...
    // but we are not creating another error just yet!
    if(isNaN(timeout)) {
      throw IntegerRange;
    }
    args[0] = timeout;
  }else if(cmd === Constants.SUBCOMMAND.client.kill.name) {
    // kill by ip:port
    if(args.length === 1) {
      conn = this.state.getByAddr('' + args[0]);
      if(!conn) {
        throw NoSuchClient;
      }
      //console.dir('found kill connection');
      args[0] = conn;
    }
  }else if(cmd === Constants.SUBCOMMAND.client.setname.name) {
    // redis appears to allow every thing but whitespace
    if(/\s+/.test(args[0])) {
      throw ClientName;
    }
  }
}
1228279
def Validate(self):
    """"""
    if len(self.RECURSION_REGEX.findall(self._value)) > 1:
      raise ValueError("Only one ** is permitted per path: %s." % self._value)
307350
function validate(cmd, args, info) {
  AbstractCommand.prototype.validate.apply(this, arguments);
  var offset = 2
    , arg
    , expires;

  // need string args (except for key, value)
  args.forEach(function(a, i, arr) {
    if(i > 1) {
      arr[i] = '' + a;
    }
  })

  if(args.length > 7) {
    throw new CommandArgLength(cmd);
  }else if(args.length > 2) {
    arg = args[offset];
    while(arg !== undefined) {
      arg = arg.toLowerCase();
      args[offset] = arg;
      if(arg !== Constants.EX
        && arg !== Constants.PX
        && arg !== Constants.NX
        && arg !== Constants.XX) {
        throw CommandSyntax;
      }
      if(arg === Constants.EX || arg === Constants.PX) {
        expires = parseInt('' + args[offset + 1]);
        if(isNaN(expires)) {
          throw IntegerRange;
        }
        args[++offset] = expires;
      }
      arg = args[++offset];
    }
  }
}
674018
def validate(self):
        """"""
        super().validate()
        nb_entities = len(self.entities)
        if nb_entities != self.rows + self.columns:
            raise self.error(
                'Number of entities: %s != number of rows + '
                'number of columns: %s+%s=%s' % (
                    nb_entities, self.rows, self.columns,
                    self.rows + self.columns))
1252210
def load_subcommand(subparsers):
    """"""
    parser_analyze = subparsers.add_parser('echo_conf', help='Echo sample configuration file')
    parser_analyze.set_defaults(func=echo_conf)
712350
def validate(config):
    '''
    
    '''

    VALID_ITEMS = [
        'type', 'bytes_sent', 'bytes_recv', 'packets_sent',
        'packets_recv', 'errin', 'errout', 'dropin',
        'dropout'
    ]

    # Configuration for load beacon should be a list of dicts
    if not isinstance(config, list):
        return False, ('Configuration for network_info beacon must be a list.')
    else:

        _config = {}
        list(map(_config.update, config))

        for item in _config.get('interfaces', {}):
            if not isinstance(_config['interfaces'][item], dict):
                return False, ('Configuration for network_info beacon must '
                               'be a list of dictionaries.')
            else:
                if not any(j in VALID_ITEMS for j in _config['interfaces'][item]):
                    return False, ('Invalid configuration item in '
                                   'Beacon configuration.')
    return True, 'Valid beacon configuration'
1306388
def Validate(self):
    """"""
    # All filters can handle the input type.
    bad_filters = []
    for f in self.filters:
      try:
        f.Validate()
      except DefinitionError as e:
        bad_filters.append("%s: %s" % (f.expression, e))
    if bad_filters:
      raise DefinitionError(
          "Filters with invalid expressions: %s" % ", ".join(bad_filters))
236056
function validate(cmd, args, info) {
  info = info || {};
  var conf = info.conf || {}
    , authrequired = typeof conf.requirepass === 'string'
    , db = info.db
    , result;

  // handle quit command special case
  if(cmd === COMMANDS.QUIT) {
    // reply with an object that mimics succesful validation
    info.command = {
      cmd: cmd, args: args, def: Constants.MAP.quit, arity: true};
    return info;
  // validate command is known
  }else{
    info.command = validators.command(cmd, args, info);
  }

  // check args length (arity)
  info.command.arity = validators.arity(cmd, args, info);

  // handle authentication requests
  if(cmd === COMMANDS.AUTH) {
    info.conn.authenticated =
      validators.auth(cmd, args, info);
  // handle unauthenticated requests when auth is enabled
  }else if(authrequired && !info.conn.authenticated) {
    throw AuthRequired;
  }

  // check operation on the correct type of value
  // this validation extracts keys, looks up the values
  // to determine the type of the existing value
  // the val array (or null) is assigned to the command
  // info object so that calling code may re-use it and
  // save looking up keys and values again where necessary
  info.command.value = validators.type(cmd, args, info);

  return info;
}
17445
def add_validate(subparsers):
    """"""
    validate_parser = subparsers.add_parser(
        'validate', help=add_validate.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    validate_parser.set_defaults(func=validate_parser.print_help)

    validate_subparsers = validate_parser.add_subparsers(title='Testers')

    validate_all_parser = validate_subparsers.add_parser(
        'all', help=validate.validate_all.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    validate_all_parser.set_defaults(func=validate.validate_all)

    validate_gate_parser = validate_subparsers.add_parser(
        'gate', help=validate.validate_gate.__doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    validate_gate_parser.set_defaults(func=validate.validate_gate)
803497
def validate(config):
    '''
    
    '''
    # Must be a list of dicts.
    if not isinstance(config, list):
        return False, 'Configuration for napalm beacon must be a list.'
    for mod in config:
        fun = mod.keys()[0]
        fun_cfg = mod.values()[0]
        if not isinstance(fun_cfg, dict):
            return False, 'The match structure for the {} execution function output must be a dictionary'.format(fun)
        if fun not in __salt__:
            return False, 'Execution function {} is not availabe!'.format(fun)
    return True, 'Valid configuration for the napal beacon!'
528263
def spec_check(self, auth_list, fun, args, form):
        '''
        
        '''
        if not auth_list:
            return False
        if form != 'cloud':
            comps = fun.split('.')
            if len(comps) != 2:
                # Hint at a syntax error when command is passed improperly,
                # rather than returning an authentication error of some kind.
                # See Issue #21969 for more information.
                return {'error': {'name': 'SaltInvocationError',
                                  'message': 'A command invocation error occurred: Check syntax.'}}
            mod_name = comps[0]
            fun_name = comps[1]
        else:
            fun_name = mod_name = fun
        for ind in auth_list:
            if isinstance(ind, six.string_types):
                if ind[0] == '@':
                    if ind[1:] == mod_name or ind[1:] == form or ind == '@{0}s'.format(form):
                        return True
            elif isinstance(ind, dict):
                if len(ind) != 1:
                    continue
                valid = next(six.iterkeys(ind))
                if valid[0] == '@':
                    if valid[1:] == mod_name:
                        if self.__fun_check(ind[valid], fun_name, args.get('arg'), args.get('kwarg')):
                            return True
                    if valid[1:] == form or valid == '@{0}s'.format(form):
                        if self.__fun_check(ind[valid], fun, args.get('arg'), args.get('kwarg')):
                            return True
        return False
1142101
def validate_args(args):
    """"""
    if not any([args.environment, args.stage, args.account]):
        sys.exit(NO_ACCT_OR_ENV_ERROR)
    if args.environment and args.account:
        sys.exit(ENV_AND_ACCT_ERROR)
    if args.environment and args.role:
        sys.exit(ENV_AND_ROLE_ERROR)
870566
private function validateInput()
    {
        $returnValue = (bool) false;

        
        
        $returnValue = true;
        
        /**
         * Parse the arguments from the command lines 
         * and set them into the parameter variable.
         * All the current formats are allowed:
         * <code>
         * php script.php -arg1 value1 -arg2 value2
         * php script.php --arg1 value1 --arg2 value2
         * php script.php -arg1=value1 -arg2=value2
         * php script.php --arg1=value1 --arg2=value2
         * php script.php value1 value2 //the key will be numeric
         * </code>
         */
        $i = 1;
        while($i < count($this->argv)){
        	$arg = trim($this->argv[$i]);
        	if(!empty($arg)){
        	    // command -(-)arg1=value1
        		if(preg_match("/^[\-]{1,2}\w+=(.*)+$/", $arg)){
        		    $sequence = explode('=', preg_replace("/^[\-]{1,}/", '', $arg));
	        		if(count($sequence) >= 2){
	        			$this->parameters[$sequence[0]] = $sequence[1];
	        		}
	        	}
	        	// command -(-)arg1 value1 value2
        		else if(preg_match("/^[\-]{1,2}\w+$/", $arg)){
        		    $key = preg_replace("/^[\-]{1,}/", '', $arg);
    			    $this->parameters[$key] = '';
    			    while(isset($this->argv[$i + 1]) && substr(trim($this->argv[$i + 1]),0,1)!='-') {
    			        $this->parameters[$key] .= trim($this->argv[++$i]).' ';
    			    }
    			    $this->parameters[$key] = substr($this->parameters[$key], 0, -1); 
	        	}
        	    // command value1 value2
	        	else{
	        		$this->parameters[$i] = $arg;
	        	}
        	}
        	$i++;
        }

        //replaces shortcuts by their original names
        if (isset($this->inputFormat['parameters'])) {
            foreach($this->inputFormat['parameters'] as $parameter){
            	if(isset($parameter['shortcut'])){
            		$short = $parameter['shortcut'];
            		$long = $parameter['name'];
            		if(array_key_exists($short, $this->parameters) && !array_key_exists($long, $this->parameters)){
    					$this->parameters[$long] = $this->parameters[$short];
    					unset($this->parameters[$short]);
    				}
            	}
            }
        }
        
        //one we have the parameters, we can validate it
        if(isset($this->inputFormat['min'])){
        	$min 	= (int) $this->inputFormat['min'];
        	$found 	=  count($this->parameters);
        	if($found < $min){
        		$this->err("Invalid parameter count: $found parameters found ($min expected)");
        		$returnValue = false;
        	}
        }
        
        if(isset($this->inputFormat['required']) && is_array($this->inputFormat['required']) && count($this->inputFormat['required'])){
        	
			$requireds = array();
			if(!is_array($this->inputFormat['required'][0])){
        		$requireds = array($this->inputFormat['required']);
        	}else{
        		$requireds = $this->inputFormat['required'];
        	}
        	
        	$found = false;
        	foreach($requireds as $required){
        		
        		$matched = 0;
	        	foreach($required as $parameter){
	        		if(array_key_exists($parameter, $this->parameters)){
	        			$matched++;
	        		}
	        	}
	        	if($matched == count($required)){
        			$found = true;
        			break;
	        	}
        	}
        	
        	if(!$found){
        		$this->err("Unable to find required arguments");
        		$returnValue = false;
        	}
        }
        
        if($returnValue && isset($this->inputFormat['parameters'])){
        	 foreach($this->inputFormat['parameters'] as $parameter){
        		if(isset($this->parameters[$parameter['name']])){
	        	 	$input = $this->parameters[$parameter['name']];
		        	switch($parameter['type']){
		        		case 'file': 
		       				if( !is_file($input) || 
		       					!file_exists($input) || 
		       					!is_readable($input))
		       				{
		       					$this->err("Unable to access to the file: $input");
		       					$returnValue = false;
		       				}
		       				break;
	        			case 'dir': 
	        				if( !is_dir($input) || 
	        					!is_readable($input))
	        				{
	        					$this->err("Unable to access to the directory: $input");
	        					$returnValue = false;
	        				}
	        				break;
	        			case 'path': 
	        				if( !is_dir(dirname($input)) )
	        				{
	        					$this->err("Wrong path given: $input");
	        					$returnValue = false;
	        				}
	        				break;
	        			case 'int':
	        			case 'float':
	        			case 'double':
	        				if(!is_numeric($input)){
	        					$this->err("$input is not a valid ".$parameter['type']);
	        					$returnValue = false;
	        				}
	        				break;
	        			case 'string':
	        				if(!is_string($input)){
	        					$this->err("$input is not a valid ".$parameter['type']);
	        					$returnValue = false;
	        				}
	        				break;
	        			case 'boolean':
	        				if(!is_bool($input) && strtolower($input) != 'true' && strtolower($input) != 'false' && !empty($input)){
	        					$this->err("$input is not a valid ".$parameter['type']);
	        					$returnValue = false;
	        				}else{
	        					if(is_bool($input)){
	        						$this->parameters[$parameter['name']] = $input = settype($input, 'boolean');
	        					}
	        					else if(!empty($input)){
	        						$this->parameters[$parameter['name']] = ((strtolower($input) == 'true') ? true : false);
	        					}
	        					else{
	        						$this->parameters[$parameter['name']] = true;
	        					}
	        				}
	        				break;
	        				
	        		}
        		}
        	}
        }
        
 
        
        

        return (bool) $returnValue;
    }
1275374
def Validate(self):
    """"""
    self._ValidateReturnedTypes()
    self._ValidatePaths()
    self._ValidateType()
    self._ValidateRequiredAttributes()
    self._ValidateCommandArgs()
1093949
private function validate()
    {
        if (isset($this->_values[self::OPTION_HOST]) && !is_string($this->_values[self::OPTION_HOST])) {
            throw new ClientException('host should be a string');
        }

        if (isset($this->_values[self::OPTION_PORT]) && !is_int($this->_values[self::OPTION_PORT])) {
            throw new ClientException('port should be an integer');
        }

        // can use either endpoint or host/port
        $optionHost     = $this->_values[self::OPTION_HOST];
        $optionEndpoint = $this->_values[self::OPTION_ENDPOINT];
        if (isset($optionHost, $optionEndpoint)) {
            throw new ClientException('must not specify both host and endpoint');
        } else {
            if (null !== $optionHost && null === $optionEndpoint) {
                // upgrade host/port to an endpoint
                $this->_values[self::OPTION_ENDPOINT] = 'tcp://' . $this->_values[self::OPTION_HOST] . ':' . $this->_values[self::OPTION_PORT];
            }
        }

        assert(isset($this->_values[self::OPTION_ENDPOINT]));
        // set up a new endpoint, this will also validate it
        $this->getEndpoint();
        if (Endpoint::getType($this->_values[self::OPTION_ENDPOINT]) === Endpoint::TYPE_UNIX) {
            // must set port to 0 for UNIX sockets
            $this->_values[self::OPTION_PORT] = 0;
        }

        if (isset($this->_values[self::OPTION_AUTH_TYPE]) && !in_array(
                $this->_values[self::OPTION_AUTH_TYPE],
                self::getSupportedAuthTypes(),
                true
            )
        ) {
            throw new ClientException('unsupported authorization method');
        }

        if (isset($this->_values[self::OPTION_CLIENT]) && !in_array(
                $this->_values[self::OPTION_CLIENT],
                self::getSupportedClientTypes(),
                true
            )
        ) {
            throw new ClientException(
                sprintf(
                    "unsupported client value '%s'",
                    $this->_values[self::OPTION_CLIENT]
                )
            );
        }

        UpdatePolicy::validate($this->_values[self::OPTION_UPDATE_POLICY]);
        UpdatePolicy::validate($this->_values[self::OPTION_REPLACE_POLICY]);
        UpdatePolicy::validate($this->_values[self::OPTION_DELETE_POLICY]);
    }
349680
def _validate(self):
        
        for key in self:
            if key not in DEFAULTS:
                raise exceptions.ConfigurationException(
                    'Unknown configuration key "{}"! Valid configuration keys are'
                    " {}".format(key, list(DEFAULTS.keys()))
                )

        validate_queues(self["queues"])
        validate_bindings(self["bindings"])
        validate_client_properties(self["client_properties"])
855243
def _validate_cmds(self):
        

        cmd_list = list(self.rule_map.keys())

        for bp in self.blueprints:
            cmd_list.extend(bp.rule_map.keys())

        duplicate_cmds = (Counter(cmd_list) - Counter(set(cmd_list))).keys()

        assert not duplicate_cmds, 'duplicate cmds: %s' % duplicate_cmds