无法使用codeIgniter验证更改值

Here i have a list of contacts where user can add new contacts as well as edit them. Now at the add time i'm using server-side validation by codeIgniter for reduce redundancies. Also here i have a number of users that can add their contacts.

Suppose their are users named "John" and "Sara".

In this case, whenever "john" add new contact that are prevoiusly added by him, then it can't be add as duplicate contact number.

But whenever "john" add new contact that are previously added by "Sara", them it can be add . but its unable to add because CodeIgniter form_validation check unique value with entire table data.

Here is my Controller Code

 $this->form_validation->set_rules('customer_email','Email', 'trim|check_email[customer.customer_email.' .$userId. ']', array('check_email' => 'Email must be unique.'));
    $this->session->set_flashdata('check_email','Mobile must be unique');

            $this->form_validation->set_rules('customer_mobile', 'Mobile', 'required|is_unique[customer.customer_mobile]');
            $this->session->set_flashdata('contact_exists','Mobile must be unique');


    if ($this->form_validation->run()) {
        $userdata = $this->session->userdata();
        $userId = $userdata['id'];
        if (!$userId):
            redirect(site_url());
        endif;

I trying to many time but unable to fix this issue. I need your kind efforts. Thanks

Please find below solution.

First you need to remove unique check from customer_mobile.

$this->form_validation->set_rules('customer_mobile', 'Mobile', 'trim|required');

Once form_validation runs true then check customer_mobile with user in database and if it return row then return error else insert Contact.

if ($this->form_validation->run() == TRUE) {
    // $check = Check here for customer_mobile with user in database
    if($check):
       return 'Contact already exist';
    else:
       // Insert Contact 
    endif;
}

Let me know if it not works.