You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Class based after validation rules feature that was introduced in Laravel v10.8.0 breaks the ApiValidatedRequest abstraction, because it automatically invokes the after() method and expects it to return an array of additional validation rules. This break was reported, but sadly rejected. Now, consumers of the validation abstraction have their applications broken.
Possible solution
To avoid introducing a breaking chance in Athenaeum, Laravel's new feature must, sadly, be force disabled. This should be doable by overwriting the getValidatorInstance() (defined in FormRequest) and comment out the if (method_exists($this, 'after')) ... statement.
However, this is only a short term solution. The after() that is defined in ApiValidatedRequest must now be deprecated and a replacement method name must be introduced, such that the same behaviour can be kept. In the next major version, the after() method can be safely removed, documented in the migration plan and the "fix" code can be removed entirely, which will also re-enable Laravel's feature.
The text was updated successfully, but these errors were encountered:
aedart
changed the title
[Api] Laravel features breaks Api Validated Request abstraction
[Api] Laravel feature breaks Api Validated Request abstraction
Apr 20, 2023
Description
The Class based after validation rules feature that was introduced in Laravel
v10.8.0
breaks theApiValidatedRequest
abstraction, because it automatically invokes theafter()
method and expects it to return an array of additional validation rules. This break was reported, but sadly rejected. Now, consumers of the validation abstraction have their applications broken.Possible solution
To avoid introducing a breaking chance in Athenaeum, Laravel's new feature must, sadly, be force disabled. This should be doable by overwriting the
getValidatorInstance()
(defined inFormRequest
) and comment out theif (method_exists($this, 'after')) ...
statement.However, this is only a short term solution. The
after()
that is defined inApiValidatedRequest
must now be deprecated and a replacement method name must be introduced, such that the same behaviour can be kept. In the next major version, theafter()
method can be safely removed, documented in the migration plan and the "fix" code can be removed entirely, which will also re-enable Laravel's feature.The text was updated successfully, but these errors were encountered: