getUserForUpdate(); return [ 'email' => 'required|email|unique:users,email,' . $user->id, 'username' => 'nullable|unique:users,username,' . $user->id, 'password' => [ 'nullable', 'confirmed', 'min:8', 'regex:/^(?=.*[A-Za-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/' ], ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages() { return [ 'password.regex' => __('The password must be at least 8 characters long and contain at least one number and one special character (@$!%*?&).') ]; } /** * @return \Illuminate\Routing\Route|object|string */ protected function getUserForUpdate() { return $this->route('user'); } }