Validation set_rules doesn't make sense?

#1
[eluser]xwero[/eluser]
I never given it much though but the only thing the set_rules method does is copy the array you defined in the controller/model/library to a validation internal array. This means the method only wastes resources or am i missing something?

set_rules code
Code:
function set_rules($data, $rules = '')
    {
        if ( ! is_array($data))
        {
            if ($rules == '')
                return;
                
            $data[$data] = $rules;
        }
    
        foreach ($data as $key => $val)
        {
            $this->_rules[$key] = $val;
        }
    }

It may not be a big waste but in the meanwhile there are no parameters for the run method which is the method that uses the rules.

#2
[eluser]Pascal Kriete[/eluser]
When it comes down to it, you're right. It just copies. Interesting.

I like having a clean run method to be honest, why not make the _rules array public.

#3
[eluser]xwero[/eluser]
That is another good option. People should use class variables more instead of relying on methods.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.