Skip to content

Instantly share code, notes, and snippets.

@ameenross
Last active October 23, 2021 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ameenross/c96191e46f60e2ae68dd48523cc3c409 to your computer and use it in GitHub Desktop.
Save ameenross/c96191e46f60e2ae68dd48523cc3c409 to your computer and use it in GitHub Desktop.
Laravel "forbidden" validation: fail validation when an attribute is in the request
<?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'));
}
}
@ameenross
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment