code: 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);
      }
docs: 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