user(); return [ 'email' => '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,}$/' ], 'birthday' => 'nullable|date', 'role_id' => 'exists:roles,id', 'country_id' => 'exists:countries,id', 'status' => Rule::in(array_keys(UserStatus::lists())) ]; } /** * 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 (@$!%*?&).') ]; } }