@mhery createa a custom Validation rule i.e AlphaDash and then use it on the validation
Validator::make($data, [
'AlphaDash' => [
'required',
new AlphaDash
]
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I created a resource in my API to check if an given nickname exists on database, like this:
Route::get('checknickname/{nickname}', 'AuthController@check_nickname');
But I want to vallidate if the parameter nickname is alpha_dash, just like we use on an POST method, for example. How can I do this?
I found out that on check_nickname function at AuthController I can't check like this:
$request->validate([
'nickname' => 'required|alpha_dash|string',
]);
@mhery createa a custom Validation rule i.e AlphaDash and then use it on the validation
Validator::make($data, [
'AlphaDash' => [
'required',
new AlphaDash
]
]);
Please or to participate in this conversation.