php - Laravel Validation Not Working For Multi-byte Characters
Solution:
As per my comment, you can achieve this by using the regex to determine the input is 10 unicode numbers like below:
$apply_data = $request->validate([
'workshop_name' => 'required|string',
'workshop_code' => [ 'required', 'string', 'regex:/^\p{N}{10}$/u' ],
], [
'regex' => 'Workshop code must consist of 10 numbers'
]);
\p{N}
means a unicode character having the property N (number)
Answer
Solution:
First of Laravel must fix their code in order to support multi-byte characters. but for now we can use size instead of digits
$apply_data = $request->validate([
'workshop_name' => 'required|string',
'workshop_code' => 'required|string|size:10',
]);
laravel size validation uses mb_strlen()
Source