title: Set a form_validation rule from a library in CodeIgniter (PHP)
body: <p>Ok so i've got a big problem with <strong>CodeIgniter flexibility</strong>. I've many personal rules (like 20) targeting an input in a form within a huge project.</p>
  
  <p>Everything work while I use the classic "callback_" system by CodeIgniter. I just put the methods in the same class than the form check and it checks it correctly.</p>
  
  <p>My problem is :</p>
  
  <p>1) I'd like to use all these rules in another form_validation in another controller without copy/paste the code ; <strong>we all know it's dirty/evil</strong>.</p>
  
  <p>2) Ideally, i'd appreciate to put these rules in a big library, because it takes something like 800 lines and this is not a good idea to let it be in my controller ; as I said this project is quite huge.</p>
  
  <p>It's 6 hours i'm looking for a solution and there's absolutely <strong>nothing clean</strong> :</p>
  
  <ul>
  <li><p>I already have a <strong>MY_Form_Validation</strong> to put some general rules but i don't like the idea to mix my specific rules in a global class which will call it everytime vainly. Plus these rules contain many libraries, models, native CI core methods such as $this->input->post() which generate errors when I put everything in this MY_Form_Validation. Not the good solution :(</p></li>
  <li><p>I created a <strong>MY_Controller</strong> including a method named 'imports' which re-generate selected libraries methods within the controller (in PHP4 it was kind of the 'aggregate_methods' function if people are curious) ; the system works perfectly but CodeIgniter doesn't understand it. The methods can be called within the controller but it seems the framework check the $CI content to call the rules (Form_validation.php line 590 in '/system/') so it doesn't work at the end ; it's also hard to modify this core part, I prefered not touching it and gave up.</p></li>
  </ul>
  
  <blockquote>
    <p>$this->load->library('volt/lbl_validation');
    $this->imports('Lbl_validation');
    // Then you can call any $this->lbl_validation->method() with $this->method() in the controller</p>
  </blockquote>
  
  <ul>
  <li>I tried to hack CI creating a customized form_validation within my library ('lbl_validation') ; the system was a bit messy but worked. The problem is when i came back to the CI form_validation system to show error messages, it was a true spaghetti-code which wasn't working that well. <strong>Not the good solution either</strong>.</li>
  </ul>
  
  <p>I also tried some other shitty solutions but i prefer not confess it.</p>
  
  <p>Now i'm here in front of my computer asking myself <strong>why bad things happened to good people</strong>, why this is so hard to separate set_rules from the called methods in CodeIgniter, why they didn't plan ahead people could've needed to call libraries methods as rules. I don't know what to do and i'm hesitating to put a dumb require() somewhere and make it all dirty and messy like my desk right now.</p>
  
  <p>Maybe, there's someone with a good dans clean solution. All my hope are turned to the StackOverFlow community ; someone ? A crazy CI geek ?</p>
  
  <p>Thank you ;)</p>