I have a Laravel 10 project and I'm trying to validate a string that can include any character (max 11 chars), except the # char
In my controller I tried this code, using regex
$request->validate([
'code' => 'required|max:11|regex:/[^#]*/',
]);
but it doesn't work; if I wrote for example "CG#777" it accept the string, but I want it to discard.
Anyone can help me?
Try this one
$request->validate([
'code' => 'required|string|max:11|regex:/^[^#]+$/'
]);