Changeset 1536

Show
Ignore:
Timestamp:
12/14/07 16:35:13 (9 months ago)
Author:
armen
Message:

You can use php functions like trim, sha1, md5, strtoupper, etc as a rule, jus add an = at the begining of the rule name. Fixed #272
*BC Break* : you can't use trim, sha1 and md5 rules anymore you have to add an = as prefix

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/application/controllers/examples.php

    r1333 r1536  
    142142                        // Format: 
    143143                        // key          friendly name,  validation rules 
    144                         'user' => array('username',    'trim|required[1,12]|regex[[0-9]+]'), 
    145                         'pass' => array('password',    'required|sha1'), 
     144                        'user' => array('username',    '=trim|required[1,12]|regex[[0-9]+]'), 
     145                        'pass' => array('password',    'required|=sha1'), 
    146146                        'reme' => array('remember me', 'required') 
    147147                )); 
  • trunk/system/libraries/Validation.php

    r1529 r1536  
    342342                else 
    343343                { 
    344                         if ($rule === 'trim' OR $rule === 'sha1' OR $rule === 'md5') 
    345                         { 
    346                                 /** 
    347                                  * @todo safe_form_data 
    348                                  */ 
     344                        if (strpos($rule, '=') === 0) 
     345                        { 
     346                                $rule                           = substr($rule, 1); 
    349347                                $this->data[$field] = $rule($data); 
    350348                                return;