Level 122
You can extend the validator https://laravel.com/docs/5.2/validation#custom-validation-rules and pass in your code from the session,
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using Laravel 5.2,
I added a verification code input in register form,
verification code was saved in session when making it,
the question is:
How to write the validation rule of verification code in function validator,
AuthController.php
protected function validator(array $data)
{
$verification_code_session = $request->session()->get('verification_code', '');
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'verification_code' => '',// How to write the validation rule?
]);
}
Please or to participate in this conversation.