title: Creating a custom codeigniter validation rule
body: <p>I have a function in my login form that checks if the email and password match the values in the database and if so it logs the user into the system.</p>
  
  <p>I would like to display a validation error if this function returns false.</p>
  
  <p>My problem is that I am unsure how to go about creating this. The message relates to both the password and email fields so I would not want a rule for each input field just display a single message.</p>
  
  <p>I have tried using flashdata to achieve this but it only works when the page has been refreshed.</p>
  
  <p>How can I created a new validation rule solely for the function <code>$this-&gt;members_model-&gt;validate_member()</code> ?? </p>
  
  <pre><code>$this-&gt;form_validation-&gt;set_error_delimiters('&lt;div class="error"&gt;', '&lt;/div&gt;');
          $this-&gt;form_validation-&gt;set_rules('email_address', '"Email address"', 'trim|required|valid_email');
          $this-&gt;form_validation-&gt;set_rules('password', '"Password"', 'trim|required');
  
          if ($this-&gt;form_validation-&gt;run() == FALSE)
          {
              $viewdata['main_content'] = 'members/login';
              $this-&gt;load-&gt;view('includes/template', $viewdata);
          }
          else
          {       
                  if($this-&gt;members_model-&gt;validate_member())
                  {
  </code></pre>