Show
Ignore:
Timestamp:
02/20/2008 02:27:58 PM (9 months ago)
Author:
armen
Message:

Added depends_on rule.
Update the examples controller with new validation stuff. (it's not perfect yet, but it works :P)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/libraries/Validation.php

    r2082 r2088  
    534534        } 
    535535 
     536        /** 
     537         * Rule: matches. Generates an error if the field does not depend on one or more 
     538         * other fields. 
     539         * 
     540         * @param   mixed   field name 
     541         * @param   array   field names to check dependency 
     542         * @return  bool 
     543         */ 
     544        public function depends_on($field, array $fields) 
     545        { 
     546                foreach ($fields as $depends_on) 
     547                { 
     548                        if (! isset($this[$depends_on]) OR $this[$depends_on] == NULL) 
     549                                return FALSE; 
     550                } 
     551 
     552                return TRUE; 
     553        } 
     554 
    536555} // End Validation