Last active
October 23, 2021 21:41
-
-
Save ameenross/c96191e46f60e2ae68dd48523cc3c409 to your computer and use it in GitHub Desktop.
Laravel "forbidden" validation: fail validation when an attribute is in the request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AppServiceProvider | |
{ | |
public function boot() | |
{ | |
// The closure will only be called if the attribute is in the request. | |
Validator::extend('forbidden', function ($attribute, $value, $parameters) { | |
// Always return false. | |
return false; | |
}, trans('validation.custom.forbidden')); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See laravel/ideas#84