src/PeskyCMF/Traits/DataValidationHelper.php
public function validate($dataOrRequest, array $rules, array $messages = [], array $customAttributes = []) {
        $errors = $this->validateAndReturnErrors($dataOrRequest, $rules, $messages, $customAttributes);
        if (!empty($errors)) {
            $this->throwValidationErrorsResponse($errors);
        }

        return $this->extractInputFromRules($dataOrRequest, $rules);
    }
public function validate($dataOrRequest, array $rules, array $messages = [], array $customAttributes = []) {
        $errors = $this->validateAndReturnErrors($dataOrRequest, $rules, $messages, $customAttributes);
        if (!empty($errors)) {
            $this->throwValidationErrorsResponse($errors);
        }

        return $this->extractInputFromRules($dataOrRequest, $rules);
    }
Validate data and throw ValidationException if it is invalid or return validated data
@param array|Request $dataOrRequest
@param array $rules
@param array $messages
@param array $customAttributes
@return array - data from request filtered by rules keys
@throws ValidationException