custom rule laravel validation code example
Example 1: custom rule laravel validation
public function store()
{
$this->validate(request(), [
'song' => [function ($attribute, $value, $fail) {
if ($value <= 10) {
$fail(':attribute needs more cowbell!');
}
}]
]);
}
Example 2: validate field for existing client laravel
unique:users,username,id,1 // table, field, idcolumn, value to ignore