Validates if all required parameters are present.

@param array $given
@param array $required contains required keys

@throws MissingRequiredParameterException

@return void
484231
static function checkRequiredParameters(array $given, array $required)
    {
        foreach ($required as $key) {
            if (!array_key_exists($key, $given)) {
                throw new MissingRequiredParameterException(
                        "Missing required parameter '$key'"
                );
            }
        }
    }
103580
public function validate($args)
    {
        $matched = false;

        //validates arguments
        foreach ($args as $arg => $value) {
            //non-named option are skipped from validation
            if (is_numeric($arg)) continue;
            //validates action options
            foreach ($this->options as $option) {
                //checks if options matches specified parameter
                if ($option->matchParam($arg)) {
                    //validates option
                    if (!$option->validate($value)) {
                        throw new InvalidArgumentException($arg, $value);
                    }
                    $matched = true;
                }
            }
            if (!$matched) {
                throw new InvalidOptionException($arg);
            }
        }
        //validates required options
        foreach ($this->options as $option) {
            if (!$option->isRequired()) {
                continue;
            }

            if (!$option->getValue($args)) {
                throw new MissingRequiredArgumentException($option->getName());
            }
        }

        return true;
    }
236756
public function setRequired($required)
    {
        if ($required) {
            $this->setAttribute('required', 'required');
        } else {
            $this->removeAttribute('required');
        }
        return parent::setRequired($required);
    }
517449
protected function validateRequiredParameters(array $required, array $params)
    {
        foreach ($required as $param) {
            if (!isset($params[$param])) {
                throw new MissingArgumentException(sprintf('The "%s" parameter is required.', $param));
            }
        }
    }
1242010
protected function validate_requirements( $requirements ) {
		if ( ! count( $requirements ) ) {
			return;
		}

		if ( ! empty( $requirements['params'] ) ) {
			$this->set_params( $requirements['params'] );
		}

		foreach ( $requirements as $key => $data ) {
			switch ( $key ) {
				case 'php':
					$this->validate_php( $data );
					break;
				case 'mysql':
					$this->validate_mysql( $data );
					break;
				case 'wordpress':
					$this->validate_wordpress( $data );
					break;
			}
		}
	}
899645
protected function validateRequired()
  {
    if ($this->isRequired() && empty($this->value)) {
      $this->addError(sprintf($this->tmpl_err_required, $this->getName()));

      return false;
    }

    return true;
  }
551696
protected function checkRequiredParameters()
    {
        $missing = array_diff(
            $this->getRequiredOptions(),
            array_keys($this->getOptions())
        );
        if (!empty($missing)) {
            throw new InvalidArgumentException(
                sprintf(
                    'Missing required parameters: %s',
                    implode(', ', $missing)
                ),
                self::STATE_UNKNOWN
            );
        }

        return $this;
    }
748565
public function setRequired($required)
    {
        $this->required = (boolean) $required;
        if ($this->isRequired()) {
            $this->setAttribute('required');
            return $this;
        }

        if ($this->getAttributes()->containsKey('required')) {
                $this->getAttributes()->remove('required');
        }
        return $this;
    }
730108
def _check_load_parameters(self, **kwargs):
        
        rset = self._meta_data['required_load_parameters']
        check = _missing_required_parameters(rset, **kwargs)
        if check:
            check.sort()
            error_message = 'Missing required params: %s' % check
            raise MissingRequiredReadParameter(error_message)
22766
private function assertRequiredOptions(array $options)
    {
        $required = $this->getRequiredOptions();
        $missing = array_diff_key(array_flip($required), $options);

        if (!empty($missing)) {
            $missing = array_keys($missing);
            $missing = implode(', ', $missing);
            $template = 'Required options not defined: %s';
            $message = sprintf($template, $missing);
            throw new InvalidArgumentException($message);
        }
    }
82956
private void validateRequiredParams() {
        String[] uriStrings = getURI().split("\\?");       
        if (uriStrings.length > 0) {
	        List<String> requiredParms = extractRequiredParamsInURI(uriStrings[0]);
	        for (String param: requiredParms) {
	        	Utils.require(commandParams.containsKey(param), "missing param: " + param); 
	        }
        }
        if (metadataJson.containsKey(INPUT_ENTITY)) {
            String paramValue = metadataJson.getString(INPUT_ENTITY);
            if (paramValue != null) {
                JsonObject parametersNode = metadataJson.getJsonObject(PARAMETERS);
                if (parametersNode != null) {
                    if (parametersNode.keySet().size() == 1) {//parent node usually "params" 
                        JsonObject params = parametersNode.getJsonObject(parametersNode.keySet().iterator().next());
                        for (String param: params.keySet()) {
                            JsonObject paramNode = params.getJsonObject(param);                     
                            if (paramNode.keySet().contains(_REQUIRED)) {                                     
                                setCompound(true);
                                Utils.require(commandParams.containsKey(param), "missing param: " + param); 
                            }               
                        }       
                    }
                }
                else {
                    Utils.require(commandParams.containsKey(paramValue), "missing param: " + paramValue);       
                }
            }
        }       
 
    }
769375
protected function ensureRequiredAttributes(array $spec = [])
    {
        if (! isset($spec['attributes'])) {
            throw new MissingAttributeException(
                sprintf('The attribute "attributes" is not defined, but required.')
            );
        }

        $required = ['type', 'name'];
        foreach ($required as $key) {
            if (! isset($spec['attributes'][$key])) {
                throw new MissingAttributeException(
                    sprintf('The attribute "%s" is not defined, but required.', $key)
                );
            }
        }
    }
594897
public static function getRequiredArgsError($args, $requiredArgs)
    {
        if (!is_array($args) && !is_object($args)) {
            return sprintf(__('invalid type "%s" for $args', 'themaster'), gettype($args));
        }
        if (!is_array($requiredArgs) && !is_object($args)) {
            return sprintf(__('invalid type "%s" for $requiredArgs', 'themaster'), gettype($requiredArgs));
        }

        $missing = array();
        foreach ($requiredArgs as $req) {
            if (!@isset($args[$req]) && !@isset($args->$req)) {
                $missing[] = $req;
            }
        }
        
        if (count($missing) == 0) {
            return false;
        } else {
            return sprintf(
                __('Missing %s as %s.', 'themaster'),
                self::readableList(
                    $missing,
                    ' '.__('and').' ',
                    ', ',
                    null,
                    '"'
                ),
                (count($missing) === 1 ? 'a key' : 'keys')
            );
        }
    }
71204
public function getMissingParameterKey(array $parameters, array $requiredKeys = [])
    {
        foreach ($requiredKeys as $key) {
            if (! isset($parameters[$key])) {
                return $key;
            }
        }
    }
868309
protected function check(array $required = null):DotEnv{

		if($required === null || empty($required)){
			return $this;
		}

		foreach($required as $var){
			if(!$this->isset($var)){
				throw new \Exception('required variable not set: '.strtoupper($var));
			}
		}

		return $this;
	}
364418
protected function required_options($required, $options = array())
  {
      $required = explode(',', $required);
      foreach ($required as $r) {
          if (!array_key_exists(trim($r), $options)) {
              throw new Exception($r.' parameter is required!');
              break;

              return false;
          }
      }

      return true;
  }
183327
private function validate()
    {
        if (null === $this->provider) {
            throw new MissingProviderException('A provider must be set for converting a currency');
        }

        if (null === $this->from || null === $this->to) {
            throw new \RuntimeException('from and to parameters must be provided');
        }
    }