Validates data.

@param array $data Data to validate
@param array|null $rules Validation rules

@throws ValidationException

@return void
763150
protected function validate(array $data, array $rules = null): void
    {
        $validator = $this->validatorFactory->make($data, $rules ?? $this->getValidationRules());
        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
341808
private function validate(array $data, array $constraints, $parentPath = '')
    {
        if (is_numeric(key($constraints))) {
            $subConstrains = reset($constraints);
            $length = count($data);
            /** @noinspection ForeachInvariantsInspection */
            for ($i = 0; $i < $length; $i++) {
                $this->validate($data[$i], $subConstrains, $parentPath . '[' . $i . ']');
            }
        } else {
            foreach ($constraints as $key => $subConstrains) {
                if (!array_key_exists($key, $data)) {
                    throw new \InvalidArgumentException(
                        sprintf('Missing key %s[%s]', $parentPath, $key)
                    );
                }
                if ($subConstrains) {
                    $this->validate($data[$key], $subConstrains, $parentPath . '[' . $key . ']');
                }
            }
        }
    }
702152
protected function validate(array $data = null)
    {
        if ($this->client->getIndex() == null) {
            throw new SyncMySqlExceptions("Index cannot be null");
        }
        if ($this->client->getType() == null) {
            throw new SyncMySqlExceptions("Type cannot be null");
        }
        if ($data != null) {
            if ($data['model'] == null) {
                throw new SyncMySqlExceptions("Please provide a valid model");
            }
        }
    }
31392
public function validate( array $data ) {

		$errors = [];

		foreach( $this->fields as $field ) {

			$f = $field->name;
			$v = isset($data[$f]) ? $data[$f] : null;

			list($clean, $errors[$f]) = $field->validate($v);

			if( !$errors[$f] )
				$data[$f] = $clean;

		}

		return [
			$data,
			array_filter($errors),
		];

	}
801335
public function runValidate(array $rules = null)
    {
        // skip validation on empty rules
        if ($rules === null) {
            return true;
        }

        $success = true;
        // list each rule as single one
        foreach ($rules as $rule) {
            // 0 = field (property) name, 1 = filter name, 2 = filter value
            if ($rule[0] === null || $rule[1] === null) {
                continue;
            }

            $propertyName = $rule[0];
            $validationRule = $rule[1];
            $validationValue = null;
            if (isset($rule[2])) {
                $validationValue = $rule[2];
            }

            // check if target field defined as array and make recursive validation
            if (Any::isArray($propertyName)) {
                $cumulateValidation = true;
                foreach ($propertyName as $attrNme) {
                    // end false condition
                    if (!$this->validateRecursive($attrNme, $validationRule, $validationValue)) {
                        $cumulateValidation = false;
                    }
                }
                // assign total
                $validate = $cumulateValidation;
            } else {
                $validate = $this->validateRecursive($propertyName, $validationRule, $validationValue);
            }

            // do not change condition on "true" check's (end-false-condition)
            if ($validate === false) {
                $success = false;
            }
        }

        return $success;
    }
509755
private function tryValidateData(
        array $data,
        array $rules,
        Closure $validationFailed,
        array $messages = [],
        array $customAttributes = []
    ) {
        $validator = $this->createValidator($data, $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            call_user_func($validationFailed, $validator->errors()->getMessages());
        }
    }
575684
private function __applyValidationRules($data)
    {
        $rule = $this->get('validator');

        return ($rule ? General::validateString($data, $rule) : true);
    }
544223
protected function createValidator(array $data, array $rules)
    {
        /** @var Factory $factory */
        $factory   = app('validator');
        $validator = $factory->make($data, $rules);

        return $validator;
    }
539889
protected function validate(array &$data)
    {
        $this->validateVersion();
        $this->validateExtensions();
        $this->validateIni();
        $data = array_merge($data, ['messages' => $this->messages]);
        return $data;
    }
492797
public function assertValid(array $attributes)
    {
        $validator = $this->makeValidator($attributes);

        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
954637
public function validate($rules = [], $errors = [])
    {
        foreach ($rules as $param => $subRules) {
            $paramValue = $this->getParam($param);
            foreach ($subRules as $key => $rule) {
                $isError = false;
                if (!is_array($rule)) {
                    switch ($rule) {
                        case self::VALIDATE_REQUIRED:
                            if (is_null($paramValue)) {
                                $isError = true;
                            }
                            break;
                        case self::VALIDATE_MOBILE:
                            if (!ValidationHelper::isMobile($paramValue)) {
                                $isError = true;
                            }
                            break;
                    }
                } else {
                    switch ($key) {
                    case self::VALIDATE_ENUM:
                        if (!in_array($paramValue, $rule)) {
                            $isError = true;
                        }
                        break;
                    }
                }
                if ($isError) {
                    $errCode = self::ERROR_INVALID_PARAM;
                    $errMsg = self::errorMsg[self::ERROR_INVALID_PARAM];
                    if (is_array($rule)) {
                        $rule = $key;
                    }
                    if (isset($errors[$param][$rule]['code'])) {
                        $errCode = $errors[$param][$rule]['code'];
                    }
                    if (isset($errors[$param][$rule]['msg'])) {
                        $errMsg = str_replace('{param}', $param, $errors[$param][$rule]['msg']);
                    }
                    throw new ParamException($errMsg, $errCode);
                }
            }
        }
    }
700362
public function validate($data = null)
    {
        if ($data !== null) {
            $this->setData($data);
        }
        // data was already validated, return the results immediately
        if ($this->wasValidated === true) {
            return $this->wasValidated && count($this->messages) === 0;
        }
        foreach ($this->rules as $selector => $valueValidator) {
            foreach ($this->getDataWrapper()->getItemsBySelector($selector) as $valueIdentifier => $value) {
                /* @var $valueValidator \Sirius\Validation\ValueValidator */
                if (!$valueValidator->validate($value, $valueIdentifier, $this->getDataWrapper())) {
                    foreach ($valueValidator->getMessages() as $message) {
                        $this->addMessage($valueIdentifier, $message);
                    }
                }
            }
        }
        $this->wasValidated = true;

        return $this->wasValidated && count($this->messages) === 0;
    }
1152954
public function is_valid(array $data) {

		$this->data = $this->apply_filters($data);

		$this->errors = $this->test_rules();

		return empty($this->errors);

	}
727728
public function override($data, $rules)
    {
        $this->setData($data);
        $this->setRules($rules);
        $this->setCustomMessages($this->overrideCustomMessages);
    }
1213855
public function validate(array $data = null)
    {
        $data = $data ?: $this->getInput();

        $this->validation = $this->validator->make($data, $this->rules(), $this->messages());

        if ($this->validation->fails())
        {
            $this->failed();

            return false;
        }

        return true;
    }
973785
public function validate($rules = array()) {
        if (empty($rules)) {
            $rules = $this->rules();
        }
        if ($this->validateAttribute($rules)) {
            return true;
        }
        Factory::log()->error('model validate error', $this->getError());
        return false;
    }
216935
public static function validate($data)
    {
        if (count(array_intersect_key(array_flip(static::$requiredParams), $data)) === count(static::$requiredParams)) {
            return true;
        }

        throw new InvalidArgumentException();
    }