How do I get CodeIgniter to run custom rules on fields which **don't** have the `required` rule but **the user left empty**?

The best I can come up with is to add a space to the field if the string is empty, and then add a `trim` rule -- but this feels hacky.

### Example rule #1

Field is required only if another field has a certain value:

```
// depends[another_field.some_val]
public function depends($str, $field){
    list($post_key, $post_val)=explode('.', $field);
    if($_POST[$post_key] == $post_val){
        return $str != "";
    }
    return true;
}

```

### Example rule #2

Field is required only if a regex exists on the database:

```
// regex[table_name.col_name.some_val]
public function regex($str, $field){
  list($table, $col, $post_val)=explode('.', $field);
  // Grab the regex
  $regex = $this->CI  ->db
                      ->limit(1)
                      ->select($col)
                      ->where($post_val, $_POST[$post_val])
                      ->get($table)
                      ->row($col);

  return preg_match('/'.$regex.'/', $str) === 1;
}

```