Skip to content

Commit

Permalink
Disable "after validation rules" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
aedart committed Apr 20, 2023
1 parent 3c6b1f8 commit 59a9a4e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/Http/Api/src/Requests/ValidatedApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Aedart\Http\Api\Requests;

use Illuminate\Contracts\Validation\Factory as ValidationFactory;
use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\ValidationException;
Expand Down Expand Up @@ -39,6 +40,41 @@ protected function prepareForValidation()
}
}

/**
* @inheritdoc
*/
protected function getValidatorInstance()
{
if ($this->validator) {
return $this->validator;
}

$factory = $this->container->make(ValidationFactory::class);

if (method_exists($this, 'validator')) {
$validator = $this->container->call([$this, 'validator'], compact('factory'));
} else {
$validator = $this->createDefaultValidator($factory);
}

if (method_exists($this, 'withValidator')) {
$this->withValidator($validator);
}

// TODO: This disables the "after validation rules" feature introduced by Laravel in v10.8.0
// TODO @see https:/aedart/athenaeum/issues/167
// if (method_exists($this, 'after')) {
// $validator->after($this->container->call(
// $this->after(...),
// ['validator' => $validator]
// ));
// }

$this->setValidator($validator);

return $this->validator;
}

/**
* Perform post request data validation, e.g. business logic validation
*
Expand Down

0 comments on commit 59a9a4e

Please sign in to comment.