The alpha_dash validate rule which defined in Illuminate\Validation\Concerns\ValidatesAttributes@validateAlphaDash is using preg_match('/^[\pL\pM\pN_-]+$/u', $value) > 0
However, it will allow input when input is non-english, for example, typing "璞嗗瓙" in Chinese, it is a valid content.
I think it should remove "\pL" to allow any languages in regex rule.
@ChiVincent steps to reproduce? is there any other validation rule on that filed or just alphadash?
app/Http/Controllers/TestController:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
class TestController extends Controller
{
public function getIndex(Request $request)
{
$validator = Validator::make($request->query(), [
'name' => 'alpha_dash',
]);
dd($validator->fails());
}
}
router/web.php
<?php
Route::get('/test', 'TestController@getIndex');
When I use test.app/test?name=aaa, it show false;
When I use test.app/test?name=aaa!, it show true;
When I use test.app/test?name=璞嗗瓙, it show false, however, the word "璞嗗瓙" should not an alpha-numeric character, should it?
however, the word "璞嗗瓙" should not an alpha-numeric character
Why not?
"Alphanumeric" doesn't just refer to Latin letters https://en.wikipedia.org/wiki/Alphanumeric
Alphanumeric is a combination of alphabetic and numeric characters, and is used to describe the collection of Latin letters and Arabic digits or a text constructed from this collection.
-- Alphanumeric Wikipedia
Although the merriam-webster said that "alphanumeric" may often additionally refer to other symbols (such as punctuation marks and mathematical symbols), in POSIX/C there are either 36 (A-Z + 0-9, case insensitive) or 62 (A-Z + a-z + 0-9, case-sensitive)
What rule definition of validation in Laravel use? Is merriam-webster dictionary or POSIX/C?
@ChiVincent you can create your own validation rule or override the current to meet your expectations if you want, this looks like an opinionated issue and keeping the discussion may lead us to nowhere :)
Closing this issue but will try to keep track if others shared your concern and reported the same thing as an issue.
Thanks