Validate the rates array.

@param array $rates

@throws \InvalidArgumentException
353873
private function validateRates(array $rates)
    {
        foreach ($rates as $rate) {
            if (!is_scalar($rate)) {
                throw new \InvalidArgumentException(sprintf(
                    'Rates passed to the PhpArray service must be scalars, "%s" given.',
                    gettype($rate)
                ));
            }
        }
    }
689655
private function validateHttpMethods(array $methods): array
    {
        if (empty($methods)) {
            throw new InvalidArgumentException(
                'HTTP methods argument was empty; must contain at least one method'
            );
        }
        if (false === array_reduce($methods, function ($valid, $method) {
            if (false === $valid) {
                return false;
            }
            if (! is_string($method)) {
                return false;
            }
            //if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
            if (! preg_match("/^[!#$%&'*+.^_`|~0-9a-z-]+$/i", $method)) {
                return false;
            }

            return $valid;
        }, true)) {
            throw new InvalidArgumentException('One or more HTTP methods were invalid');
        }

        return array_map('strtoupper', $methods);
    }
1297320
public static function validateMultiple($keys)
    {
        foreach ($keys as $key) {
            if (!is_string($key) && !is_int($key)) {
                throw InvalidKeyException::forKey($key);
            }
        }
    }
698648
private function assertHeaders(array $headers)
    {
        foreach ($headers as $name => $headerValues) {
            HeaderSecurity::assertValidName($name);
            array_walk($headerValues, __NAMESPACE__ . '\HeaderSecurity::assertValid');
        }
    }
569866
public function validateHeader(array $header)
    {
        if (!isset($header['alg'])) {
            throw new \InvalidArgumentException("Missing 'alg' in header");
        }
        if (!isset($header['typ'])) {
            throw new \InvalidArgumentException("Missing 'typ' in header");
        }
        if ($this->type !== $header['alg']) {
            throw new \InvalidArgumentException("Algorithm mismatch");
        }
    }
1171034
public function setErrors($errors = array())
    {
        foreach ($errors as $error) {
            if (!$error instanceof ConstraintViolation) {
                throw new \InvalidArgumentException(sprintf('The supplied error is of class "%s", while a "Symfony\Component\Validator\ConstraintViolation" was expected.', get_class($error)));
            }
        }

        $this->errors = $errors;
    }
779568
public function fit(array $values) : void
    {
        if (empty($values)) {
            throw new InvalidArgumentException('Strategy must be fit with'
                . ' at least 1 value.');
        }

        $this->min = min($values);
        $this->max = max($values);
    }
431377
protected function setExchangeRate(float $exchangeRate): void
    {
        if ( ! is_float($exchangeRate)) {
            throw new \InvalidArgumentException(sprintf('ExchangeRate has to be a float. %s given.', gettype($exchangeRate)));
        }

        $this->exchangeRate = $exchangeRate;
    }
1105412
protected function iterate($values)
    {
        if (!is_object($values) && !is_array($values)) {
            throw new \InvalidArgumentException("Unable to validate provided object");
        }
        $errors = [];
        foreach ($this->ruleset as $field => $rules) {
            $value = $this->access($values, $field);
            $error = $rules->apply($value, $values);
            if ($error !== null) {
                $errors[$field] = count($error) > 1 || count(array_filter(array_keys($error), 'is_string')) > 0 ?
                    $error : current($error);
            }
        }
        return $errors;
    }
202042
private function validateInput( $settings ) {
        if ( !isset( $settings["serverUrl"] ) ||
             !isset( $settings["username"] ) ||
             !isset( $settings["password"] )
        ) {
            throw new \InvalidArgumentException( 'Username, password or serverUrl is incorrect' );
        }

        if ( !filter_var( $settings["serverUrl"], FILTER_VALIDATE_URL )
             || strpos( $settings["serverUrl"], "." ) === false
        ) {
            throw new \InvalidArgumentException( 'Invalid serverUrl has been provided' );
        }

        if ( !in_array( $settings['authMode'], [ 'OnlineFederation', 'Federation' ] ) ) {
            throw new \InvalidArgumentException( 'Provided authentication mode <' . $this->authMode . '> is not supported' );
        }
    }
216478
private function validateKeys(array $keys)
    {
        foreach ($keys as $key) {
            $key = (string)$key;
            $this->validateKey($key);
        }
    }
226329
public function setValues($values)
    {
        if ((null !== $values) && (false === is_array($values))) {
            if (false === ($values instanceof ArrayAccess)) {
                throw new InvalidArgumentException(
                    'The value of $values is not an array or an instance of ArrayAccess.'
                );
            }
        }

        $this->values = $values;
    }
1220903
private function checkFiles(array $files) : void
    {
        foreach ($files as $value) {
            if (is_array($value)) {
                $this->checkFiles($value);
            } elseif (! $value instanceof UploadedFile) {
                $type = is_object($value) ? get_class($value) : gettype($value);

                throw new \InvalidArgumentException('Expected ' . UploadedFile::class . ' or array, got ' . $type);
            }
        }
    }
1322792
public function each($attribute, $rules)
    {
        $data = array_get($this->data, $attribute);

        if (!is_array($data)) {
            if ($this->hasRule($attribute, 'Array')) {
                return;
            }

            throw new \InvalidArgumentException('Attribute for each() must be an array.');
        }

        foreach ($data as $dataKey => $dataValue) {
            foreach ($rules as $ruleValue) {
                $this->mergeRules("$attribute.$dataKey", $ruleValue);
            }
        }
    }
1246515
private function validateInput($values)
    {
        if (!array_key_exists("name",$values))
        {
            throw new InvalidArgumentException("You must supply a name.");
        }

        if (!array_key_exists("number",$values))
        {
            throw new InvalidArgumentException("You must supply a credit card number.");
        }

        if (!array_key_exists("expiration_month",$values))
        {
            throw new InvalidArgumentException("You must supply an expiration month");
        }

        if (!array_key_exists("expiration_year",$values))
        {
            throw new InvalidArgumentException("You must supply an expiration year.");
        }

        if (!array_key_exists("line1",$values))
        {
            throw new InvalidArgumentException("Line 1 of the address is missing.");
        }

        if (!array_key_exists("city",$values))
        {
            throw new InvalidArgumentException("The city of the address is missing.");
        }

        if (!array_key_exists("zip",$values))
        {
            throw new InvalidArgumentException("The ZIP/postal code of the address is missing.");
        }

        if (!array_key_exists("country",$values))
        {
            throw new InvalidArgumentException("The country of the address is missing.");
        }

        $card = CreditCardValidator::validCreditCard($values['number']);
        if ($card['valid'] !== true)
        {
            throw new InvalidArgumentException("The credit card number is not valid.");
        }

        if (CreditCardValidator::validCvc($values['cvc'], $card['type']) === false)
        {
            throw new InvalidArgumentException("The CVC is not valid.");
        }

        $month = sprintf("%02d", $values['expiration_month']);
        if (strlen($values['expiration_year']) !== 4)
        {
            throw new InvalidArgumentException("You must input a 4 digit year.");
        }

        if (!CreditCardValidator::validDate($values['expiration_year'], $month))
        {
            throw new InvalidArgumentException("Expiration date is not valid.");
        }

        if (!isset(countries()[$values['country']]))
        {
            throw new InvalidArgumentException($values['country'] . " is not a valid country.");
        }

        if (!in_array($values['country'],['US','CA']))
        {
            if (count(subdivisions($values['country'])) > 0 && !in_array($values['state'],subdivisions($values['country'])))
            {
                throw new InvalidArgumentException($values['state'] . " is not a valid state.");
            }
        }
        else
        {
            if (!isset(subdivisions($values['country'])[$values['state']]))
            {
                throw new InvalidArgumentException($values['state'] . " is not a valid state.");
            }
        }
    }
1034404
public function setMethods(array $methods) {
        foreach ($methods as $method) {
            if ( ! HttpRequestMethod::isValid($method)) {
                throw new Exception(
                    s(
                        'Invalid request method %s. Valid methods are %s.',
                        $method, implode(', ', HttpRequestMethod::getMethods())
                    )
                );
            }
        }

        $this->methods = $methods;
    }
270340
private function isValidElements(array $elements): void
    {
        $this->isValidArray($elements, 1, 1);
        foreach ($elements as $element) {
            if (!$element instanceof MediaElement) {
                throw new InvalidClassException(sprintf('Array can only contain instance of %s.', MediaElement::class));
            }
        }
    }