Skip to content

Instantly share code, notes, and snippets.

@lomotech
Created September 20, 2018 03:22
Show Gist options
  • Save lomotech/fe619ab13f8d61087c0c42fab69b7c03 to your computer and use it in GitHub Desktop.
Save lomotech/fe619ab13f8d61087c0c42fab69b7c03 to your computer and use it in GitHub Desktop.
laravel custom validation
public function boot()
{
Validator::extend('both_not_filled', function ($attribute, $value, $parameters) {
$other = $parameters[0];
if (!empty($value) && !empty($other)) {
return false;
}
return true;
});
}
'foo' => 'both_not_filled:',$request->get('bar')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment