src/Validation/ErrorTranslator.php
public function failedValidator(ValidatorContract $validator, \Closure $closure = null): ErrorCollection
    {
        $failed = $this->doesIncludeFailed() ? $validator->failed() : [];
        $errors = new ErrorCollection();

        foreach ($validator->errors()->messages() as $key => $messages) {
            $failures = $this->createValidationFailures($failed[$key] ?? []);

            foreach ($messages as $detail) {
                $failed = $failures->shift() ?: [];

                if ($closure) {
                    $errors->add($this->call($closure, $key, $detail, $failed));
                    continue;
                }

                $errors->add(new Error(
                    null,
                    null,
                    Response::HTTP_UNPROCESSABLE_ENTITY,
                    $this->trans('failed_validator', 'code'),
                    $this->trans('failed_validator', 'title'),
                    $detail ?: $this->trans('failed_validator', 'detail')
                ));
            }
        }

        return $errors;
    }
public function failedValidator(ValidatorContract $validator, \Closure $closure = null): ErrorCollection
    {
        $failed = $this->doesIncludeFailed() ? $validator->failed() : [];
        $errors = new ErrorCollection();

        foreach ($validator->errors()->messages() as $key => $messages) {
            $failures = $this->createValidationFailures($failed[$key] ?? []);

            foreach ($messages as $detail) {
                $failed = $failures->shift() ?: [];

                if ($closure) {
                    $errors->add($this->call($closure, $key, $detail, $failed));
                    continue;
                }

                $errors->add(new Error(
                    null,
                    null,
                    Response::HTTP_UNPROCESSABLE_ENTITY,
                    $this->trans('failed_validator', 'code'),
                    $this->trans('failed_validator', 'title'),
                    $detail ?: $this->trans('failed_validator', 'detail')
                ));
            }
        }

        return $errors;
    }
Create errors for a failed validator.

@param ValidatorContract $validator
@param \Closure|null $closure
a closure that is bound to the translator.
@return ErrorCollection