code: public function createValidator(
          array $data,
          array $rules,
          array $messages = [],
          array $customAttributes = [],
          \Closure $callback = null
      ): ValidatorInterface
      {
          $translator = $this->createErrorTranslator();
  
          return new Validation\Validator(
              $this->makeValidator($data, $rules, $messages, $customAttributes),
              $translator,
              $callback
          );
      }
docs: Create a Laravel validator that has JSON API error objects.
  
  @param array $data
  @param array $rules
  @param array $messages
  @param array $customAttributes
  @param \Closure|null $callback
  a closure for creating an error, that will be bound to the error translator.
  @return ValidatorInterface