root

Changeset 651

Show
Ignore:
Timestamp:
07/13/09 23:02:17 (1 year ago)
Author:
wbond
Message:

BackwardsCompatibilityBreak - renamed fORMValidation::addConditionalValidationRule() to fORMValidation::addConditionalRule(), fORMValidation::addManyToManyValidationRule() to fORMValidation::addManyToManyRule(), fORMValidation::addOneOrMoreValidationRule() to fORMValidation::addOneOrMoreRule(), fORMValidation::addOneToManyValidationRule() to fORMValidation::addOneToManyRule(), fORMValidation::addOnlyOneValidationRule() to fORMValidation::addOnlyOneRule(), fORMValidation::addValidValuesValidationRule() to fORMValidation::addValidValuesRule()

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fORMValidation.php

    r649 r651 Hide Line Numbers
    1111 * @link       http://flourishlib.com/fORMValidation 
    1212 *  
    13  * @version    1.0.0b15 
     13 * @version    1.0.0b16 
     14 * @changes    1.0.0b16  Backwards Compatibility Break - renamed ::addConditionalValidationRule() to ::addConditionalRule(), ::addManyToManyValidationRule() to ::addManyToManyRule(), ::addOneOrMoreValidationRule() to ::addOneOrMoreRule(), ::addOneToManyValidationRule() to ::addOneToManyRule(), ::addOnlyOneValidationRule() to ::addOnlyOneRule(), ::addValidValuesValidationRule() to ::addValidValuesRule() [wb, 2009-07-13] 
    1415 * @changes    1.0.0b15  Added ::addValidValuesValidationRule() [wb/jt, 2009-07-13] 
    1516 * @changes    1.0.0b14  Added ::addStringReplacement() and ::addRegexReplacement() for simple validation message modification [wb, 2009-07-01] 
     
    3132{ 
    3233    // The following constants allow for nice looking callbacks to static methods 
    33     const addConditionalValidationRule = 'fORMValidation::addConditionalValidationRule'; 
    34     const addManyToManyValidationRule  = 'fORMValidation::addManyToManyValidationRule'; 
    35     const addOneOrMoreValidationRule   = 'fORMValidation::addOneOrMoreValidationRule'; 
    36     const addOneToManyValidationRule   = 'fORMValidation::addOneToManyValidationRule'; 
    37     const addOnlyOneValidationRule     = 'fORMValidation::addOnlyOneValidationRule'; 
    38     const addRegexReplacement          = 'fORMValidation::addRegexReplacement'; 
    39     const addStringReplacement         = 'fORMValidation::addStringReplacement'; 
    40     const addValidValuesValidationRule = 'fORMValidation::addValidValuesValidationRule'; 
    41     const inspect                      = 'fORMValidation::inspect'; 
    42     const reorderMessages              = 'fORMValidation::reorderMessages'; 
    43     const replaceMessages              = 'fORMValidation::replaceMessages'; 
    44     const reset                        = 'fORMValidation::reset'; 
    45     const setColumnCaseInsensitive     = 'fORMValidation::setColumnCaseInsensitive'; 
    46     const setMessageOrder              = 'fORMValidation::setMessageOrder'; 
    47     const validate                     = 'fORMValidation::validate'; 
    48     const validateRelated              = 'fORMValidation::validateRelated';    
     34    const addConditionalRule       = 'fORMValidation::addConditionalRule'; 
     35    const addManyToManyRule        = 'fORMValidation::addManyToManyRule'; 
     36    const addOneOrMoreRule         = 'fORMValidation::addOneOrMoreRule'; 
     37    const addOneToManyRule         = 'fORMValidation::addOneToManyRule'; 
     38    const addOnlyOneRule           = 'fORMValidation::addOnlyOneRule'; 
     39    const addRegexReplacement      = 'fORMValidation::addRegexReplacement'; 
     40    const addStringReplacement     = 'fORMValidation::addStringReplacement'; 
     41    const addValidValuesRule       = 'fORMValidation::addValidValuesRule'; 
     42    const inspect                  = 'fORMValidation::inspect'; 
     43    const reorderMessages          = 'fORMValidation::reorderMessages'; 
     44    const replaceMessages          = 'fORMValidation::replaceMessages'; 
     45    const reset                    = 'fORMValidation::reset'; 
     46    const setColumnCaseInsensitive = 'fORMValidation::setColumnCaseInsensitive'; 
     47    const setMessageOrder          = 'fORMValidation::setMessageOrder'; 
     48    const validate                 = 'fORMValidation::validate'; 
     49    const validateRelated          = 'fORMValidation::validateRelated';    
    4950     
    5051     
     
    5758     
    5859    /** 
    59      * Conditional validation rules 
     60     * Conditional rules 
    6061     *  
    6162     * @var array 
    6263     */ 
    63     static private $conditional_validation_rules = array(); 
    64      
    65     /** 
    66      * Ordering rules for validation messages 
     64    static private $conditional_rules = array(); 
     65     
     66    /** 
     67     * Ordering rules for messages 
    6768     *  
    6869     * @var array 
     
    7172     
    7273    /** 
    73      * One or more validation rules 
     74     * One or more rules 
    7475     *  
    7576     * @var array 
    7677     */ 
    77     static private $one_or_more_validation_rules = array(); 
    78      
    79     /** 
    80      * Only one validation rules 
     78    static private $one_or_more_rules = array(); 
     79     
     80    /** 
     81     * Only one rules 
    8182     *  
    8283     * @var array 
    8384     */ 
    84     static private $only_one_validation_rules = array(); 
    85      
    86     /** 
    87      * Regular expression replacements performed on each validation message 
     85    static private $only_one_rules = array(); 
     86     
     87    /** 
     88     * Regular expression replacements performed on each message 
    8889     *  
    8990     * @var array 
     
    9293     
    9394    /** 
    94      * Validation rules that require at least one or more *-to-many related records to be associated 
     95     * Rules that require at least one or more *-to-many related records to be associated 
    9596     *  
    9697     * @var array 
    9798     */ 
    98     static private $related_one_or_more_validation_rules = array(); 
    99      
    100     /** 
    101      * String replacements performed on each validation message 
     99    static private $related_one_or_more_rules = array(); 
     100     
     101    /** 
     102     * String replacements performed on each message 
    102103     *  
    103104     * @var array 
     
    106107     
    107108    /** 
    108      * Valid values validation rules 
     109     * Valid values rules 
    109110     *  
    110111     * @var array 
    111112     */ 
    112     static private $valid_values_validation_rules = array(); 
    113      
    114      
    115     /** 
    116      * Adds a conditional validation rule 
     113    static private $valid_values_rules = array(); 
     114     
     115     
     116    /** 
     117     * Adds a conditional rule 
    117118     *  
    118119     * If a non-empty value is found in one of the `$main_columns`, or if 
     
    120121     * `$conditional_columns` will also be required to have a value. 
    121122     * 
    122      * @param  mixed         $class                The class name or instance of the class this validation rule applies to 
     123     * @param  mixed         $class                The class name or instance of the class this rule applies to 
    123124     * @param  string|array  $main_columns         The column(s) to check for a value 
    124125     * @param  mixed         $conditional_values   If `NULL`, any value in the main column will trigger the conditional column(s), otherwise the value must match this scalar value or be present in the array of values 
     
    126127     * @return void 
    127128     */ 
    128     static public function addConditionalValidationRule($class, $main_columns, $conditional_values, $conditional_columns) 
     129    static public function addConditionalRule($class, $main_columns, $conditional_values, $conditional_columns) 
    129130    { 
    130131        $class = fORM::getClass($class); 
    131132         
    132         if (!isset(self::$conditional_validation_rules[$class])) { 
    133             self::$conditional_validation_rules[$class] = array(); 
     133        if (!isset(self::$conditional_rules[$class])) { 
     134            self::$conditional_rules[$class] = array(); 
    134135        } 
    135136         
     
    145146        $rule['conditional_columns'] = $conditional_columns; 
    146147         
    147         self::$conditional_validation_rules[$class][] = $rule; 
    148     } 
    149      
    150      
    151     /** 
    152      * Add a many-to-many validation rule that requires at least one related record is associated with the current record 
     148        self::$conditional_rules[$class][] = $rule; 
     149    } 
     150     
     151     
     152    /** 
     153     * Add a many-to-many rule that requires at least one related record is associated with the current record 
    153154     * 
    154155     * @param  mixed  $class          The class name or instance of the class to add the rule for 
     
    157158     * @return void 
    158159     */ 
    159     static public function addManyToManyValidationRule($class, $related_class, $route=NULL) 
     160    static public function addManyToManyRule($class, $related_class, $route=NULL) 
    160161    { 
    161162        $class = fORM::getClass($class); 
    162163         
    163         if (!isset(self::$related_one_or_more_validation_rules[$class])) { 
    164             self::$related_one_or_more_validation_rules[$class] = array(); 
    165         } 
    166          
    167         if (!isset(self::$related_one_or_more_validation_rules[$class][$related_class])) { 
    168             self::$related_one_or_more_validation_rules[$class][$related_class] = array(); 
     164        if (!isset(self::$related_one_or_more_rules[$class])) { 
     165            self::$related_one_or_more_rules[$class] = array(); 
     166        } 
     167         
     168        if (!isset(self::$related_one_or_more_rules[$class][$related_class])) { 
     169            self::$related_one_or_more_rules[$class][$related_class] = array(); 
    169170        } 
    170171         
     
    176177        ); 
    177178         
    178         self::$related_one_or_more_validation_rules[$class][$related_class][$route] = TRUE; 
    179     } 
    180      
    181      
    182     /** 
    183      * Adds a one-or-more validation rule that requires at least one of the columns specified has a value 
     179        self::$related_one_or_more_rules[$class][$related_class][$route] = TRUE; 
     180    } 
     181     
     182     
     183    /** 
     184     * Adds a one-or-more rule that requires at least one of the columns specified has a value 
    184185     * 
    185186     * @param  mixed $class    The class name or instance of the class the columns exists in 
     
    187188     * @return void 
    188189     */ 
    189     static public function addOneOrMoreValidationRule($class, $columns) 
     190    static public function addOneOrMoreRule($class, $columns) 
    190191    { 
    191192        $class = fORM::getClass($class); 
     
    193194        settype($columns, 'array'); 
    194195         
    195         if (!isset(self::$one_or_more_validation_rules[$class])) { 
    196             self::$one_or_more_validation_rules[$class] = array(); 
     196        if (!isset(self::$one_or_more_rules[$class])) { 
     197            self::$one_or_more_rules[$class] = array(); 
    197198        } 
    198199         
     
    200201        $rule['columns'] = $columns; 
    201202         
    202         self::$one_or_more_validation_rules[$class][] = $rule; 
    203     } 
    204      
    205      
    206     /** 
    207      * Add a one-to-many validation rule that requires at least one related record is associated with the current record 
     203        self::$one_or_more_rules[$class][] = $rule; 
     204    } 
     205     
     206     
     207    /** 
     208     * Add a one-to-many rule that requires at least one related record is associated with the current record 
    208209     * 
    209210     * @param  mixed  $class          The class name or instance of the class to add the rule for 
     
    212213     * @return void 
    213214     */ 
    214     static public function addOneToManyValidationRule($class, $related_class, $route=NULL) 
     215    static public function addOneToManyRule($class, $related_class, $route=NULL) 
    215216    { 
    216217        $class = fORM::getClass($class); 
    217218         
    218         if (!isset(self::$related_one_or_more_validation_rules[$class])) { 
    219             self::$related_one_or_more_validation_rules[$class] = array(); 
    220         } 
    221          
    222         if (!isset(self::$related_one_or_more_validation_rules[$class][$related_class])) { 
    223             self::$related_one_or_more_validation_rules[$class][$related_class] = array(); 
     219        if (!isset(self::$related_one_or_more_rules[$class])) { 
     220            self::$related_one_or_more_rules[$class] = array(); 
     221        } 
     222         
     223        if (!isset(self::$related_one_or_more_rules[$class][$related_class])) { 
     224            self::$related_one_or_more_rules[$class][$related_class] = array(); 
    224225        } 
    225226         
     
    231232        ); 
    232233         
    233         self::$related_one_or_more_validation_rules[$class][$related_class][$route] = TRUE; 
    234     } 
    235      
    236      
    237     /** 
    238      * Add an only-one validation rule that requires exactly one of the columns must have a value 
     234        self::$related_one_or_more_rules[$class][$related_class][$route] = TRUE; 
     235    } 
     236     
     237     
     238    /** 
     239     * Add an only-one rule that requires exactly one of the columns must have a value 
    239240     * 
    240241     * @param  mixed $class    The class name or instance of the class the columns exists in 
     
    242243     * @return void 
    243244     */ 
    244     static public function addOnlyOneValidationRule($class, $columns) 
     245    static public function addOnlyOneRule($class, $columns) 
    245246    { 
    246247        $class = fORM::getClass($class); 
     
    248249        settype($columns, 'array'); 
    249250         
    250         if (!isset(self::$only_one_validation_rules[$class])) { 
    251             self::$only_one_validation_rules[$class] = array(); 
     251        if (!isset(self::$only_one_rules[$class])) { 
     252            self::$only_one_rules[$class] = array(); 
    252253        } 
    253254         
     
    255256        $rule['columns'] = $columns; 
    256257         
    257         self::$only_one_validation_rules[$class][] = $rule; 
    258     } 
    259      
    260      
    261     /** 
    262      * Adds a call to [http://php.net/oreg_replace `preg_replace()`] for each validation message 
     258        self::$only_one_rules[$class][] = $rule; 
     259    } 
     260     
     261     
     262    /** 
     263     * Adds a call to [http://php.net/oreg_replace `preg_replace()`] for each message 
    263264     *  
    264265     * Regex replacement is done after the `post::validate()` hook, and right 
    265      * before the validation messages are reordered. 
    266      *  
    267      * If a validation message is an empty string after replacement, it will be 
    268      * removed from the list of validation messages. 
     266     * before the messages are reordered. 
     267     *  
     268     * If a message is an empty string after replacement, it will be 
     269     * removed from the list of messages. 
    269270     *  
    270271     * @param  mixed  $class    The class name or instance of the class the columns exists in 
     
    290291     
    291292    /** 
    292      * Adds a call to [http://php.net/str_replace `str_replace()`] for each validation message 
     293     * Adds a call to [http://php.net/str_replace `str_replace()`] for each message 
    293294     *  
    294295     * String replacement is done after the `post::validate()` hook, and right 
    295      * before the validation messages are reordered. 
    296      *  
    297      * If a validation message is an empty string after replacement, it will be 
    298      * removed from the list of validation messages. 
     296     * before the messages are reordered. 
     297     *  
     298     * If a message is an empty string after replacement, it will be 
     299     * removed from the list of messages. 
    299300     *  
    300301     * @param  mixed  $class    The class name or instance of the class the columns exists in 
     
    328329     * on the column in the database, or using a MySQL `ENUM` data type. 
    329330     * 
    330      * @param  mixed   $class         The class name or instance of the class this validation rule applies to 
     331     * @param  mixed   $class         The class name or instance of the class this rule applies to 
    331332     * @param  string  $column        The column to validate 
    332333     * @param  array   $valid_values  The valid values to check - `NULL` values are always allows if the column is not set to `NOT NULL` 
    333334     * @return void 
    334335     */ 
    335     static public function addValidValuesValidationRule($class, $column, $valid_values) 
     336    static public function addValidValuesRule($class, $column, $valid_values) 
    336337    { 
    337338        $class = fORM::getClass($class); 
    338339         
    339         if (!isset(self::$valid_values_validation_rules[$class])) { 
    340             self::$valid_values_validation_rules[$class] = array(); 
     340        if (!isset(self::$valid_values_rules[$class])) { 
     341            self::$valid_values_rules[$class] = array(); 
    341342        } 
    342343         
    343344        settype($valid_values, 'array'); 
    344345         
    345         self::$valid_values_validation_rules[$class][$column] = $valid_values; 
     346        self::$valid_values_rules[$class][$column] = $valid_values; 
    346347         
    347348        fORM::registerInspectCallback($class, $column, self::inspect); 
     
    356357     * @param  array          &$values      An associative array of all values going into the row (needs all for multi-field unique constraint checking) 
    357358     * @param  array          &$old_values  The old values from the record 
    358      * @return string  A validation error message for the column specified 
     359     * @return string  An error message for the column specified 
    359360     */ 
    360361    static private function checkAgainstSchema($object, $column, &$values, &$old_values) 
     
    408409     
    409410    /** 
    410      * Validates against a conditional validation rule 
    411      * 
    412      * @param  string $class                The class this validation rule applies to 
     411     * Validates against a conditional rule 
     412     * 
     413     * @param  string $class                The class this rule applies to 
    413414     * @param  array  &$values              An associative array of all values for the record 
    414415     * @param  array  $main_columns         The columns to check for a value 
    415416     * @param  array  $conditional_values   If `NULL`, any value in the main column will trigger the conditional columns, otherwise the value must match one of these 
    416417     * @param  array  $conditional_columns  The columns that are to be required 
    417      * @return array  The validation error messages for the rule specified 
     418     * @return array  The error messages for the rule specified 
    418419     */ 
    419420    static private function checkConditionalRule($class, &$values, $main_columns, $conditional_values, $conditional_columns) 
     
    454455     * @param  string $column  The column to check 
    455456     * @param  mixed  $value   The value to check 
    456      * @return string  A validation error message for the column specified 
     457     * @return string  An error message for the column specified 
    457458     */ 
    458459    static private function checkDataType($class, $column, $value) 
     
    525526     * @param  string $column   The column to check 
    526527     * @param  array  &$values  The values to check 
    527      * @return string  A validation error message for the column specified 
     528     * @return string  An error message for the column specified 
    528529     */ 
    529530    static private function checkForeignKeyConstraints($class, $column, &$values) 
     
    559560     
    560561    /** 
    561      * Validates against a one-or-more validation rule 
     562     * Validates against a one-or-more rule 
    562563     * 
    563564     * @param  string $class    The class the columns are part of 
    564565     * @param  array  &$values  An associative array of all values for the record 
    565566     * @param  array  $columns  The columns to check 
    566      * @return string  A validation error message for the rule 
     567     * @return string  An error message for the rule 
    567568     */ 
    568569    static private function checkOneOrMoreRule($class, &$values, $columns) 
     
    591592     
    592593    /** 
    593      * Validates against an only-one validation rule 
     594     * Validates against an only-one rule 
    594595     * 
    595596     * @param  string $class    The class the columns are part of 
    596597     * @param  array  &$values  An associative array of all values for the record 
    597598     * @param  array  $columns  The columns to check 
    598      * @return string  A validation error message for the rule 
     599     * @return string  An error message for the rule 
    599600     */ 
    600601    static private function checkOnlyOneRule($class, &$values, $columns) 
     
    635636     * @param  array          &$values      An associative array of all values going into the row (needs all for multi-field unique constraint checking) 
    636637     * @param  array          &$old_values  The old values for the record 
    637      * @return string  A validation error message 
     638     * @return string  An error message 
    638639     */ 
    639640    static private function checkPrimaryKeys($object, &$values, &$old_values) 
     
    703704     
    704705    /** 
    705      * Validates against a *-to-many one or more validation rule 
     706     * Validates against a *-to-many one or more rule 
    706707     * 
    707708     * @param  fActiveRecord $object            The object being checked 
     
    710711     * @param  string        $related_class     The name of the related class 
    711712     * @param  string        $route             The name of the route from the class to the related class 
    712      * @return string  A validation error message for the rule 
     713     * @return string  An error message for the rule 
    713714     */ 
    714715    static private function checkRelatedOneOrMoreRule($object, &$values, &$related_records, $related_class, $route) 
     
    742743     * @param  array          &$values      The values to check 
    743744     * @param  array          &$old_values  The old values for the record 
    744      * @return string  A validation error message for the unique constraints 
     745     * @return string  An error message for the unique constraints 
    745746     */ 
    746747    static private function checkUniqueConstraints($object, &$values, &$old_values) 
     
    814815     
    815816    /** 
    816      * Validates against a valid values validation rule 
    817      * 
    818      * @param  string $class         The class this validation rule applies to 
     817     * Validates against a valid values rule 
     818     * 
     819     * @param  string $class         The class this rule applies to 
    819820     * @param  array  &$values       An associative array of all values for the record 
    820821     * @param  string $column        The column the rule applies to 
    821822     * @param  array  $valid_values  An array of valid values to check the column against 
    822      * @return string  The validation error message for the rule specified 
     823     * @return string  The error message for the rule specified 
    823824     */ 
    824825    static private function checkValidValuesRule($class, &$values, $column, $valid_values) 
     
    871872    static private function initializeRuleArrays($class) 
    872873    { 
    873         self::$conditional_validation_rules[$class]         = (isset(self::$conditional_validation_rules[$class]))         ? self::$conditional_validation_rules[$class]         : array(); 
    874         self::$one_or_more_validation_rules[$class]         = (isset(self::$one_or_more_validation_rules[$class]))         ? self::$one_or_more_validation_rules[$class]         : array(); 
    875         self::$only_one_validation_rules[$class]            = (isset(self::$only_one_validation_rules[$class]))            ? self::$only_one_validation_rules[$class]            : array(); 
    876         self::$related_one_or_more_validation_rules[$class] = (isset(self::$related_one_or_more_validation_rules[$class])) ? self::$related_one_or_more_validation_rules[$class] : array(); 
    877         self::$valid_values_validation_rules[$class]        = (isset(self::$valid_values_validation_rules[$class]))        ? self::$valid_values_validation_rules[$class]        : array(); 
     874        self::$conditional_rules[$class]         = (isset(self::$conditional_rules[$class]))         ? self::$conditional_rules[$class]         : array(); 
     875        self::$one_or_more_rules[$class]         = (isset(self::$one_or_more_rules[$class]))         ? self::$one_or_more_rules[$class]         : array(); 
     876        self::$only_one_rules[$class]            = (isset(self::$only_one_rules[$class]))            ? self::$only_one_rules[$class]            : array(); 
     877        self::$related_one_or_more_rules[$class] = (isset(self::$related_one_or_more_rules[$class])) ? self::$related_one_or_more_rules[$class] : array(); 
     878        self::$valid_values_rules[$class]        = (isset(self::$valid_values_rules[$class]))        ? self::$valid_values_rules[$class]        : array(); 
    878879    } 
    879880     
     
    891892    static public function inspect($class, $column, &$metadata) 
    892893    { 
    893         if (!empty(self::$valid_values_validation_rules[$class][$column])) { 
    894             $metadata['valid_values'] = self::$valid_values_validation_rules[$class][$column]; 
     894        if (!empty(self::$valid_values_rules[$class][$column])) { 
     895            $metadata['valid_values'] = self::$valid_values_rules[$class][$column]; 
    895896        } 
    896897    } 
     
    929930     * @internal 
    930931     *  
    931      * @param  string $class                The class to reorder messages for 
    932      * @param  array  $validation_messages  An array of the validation messages 
    933      * @return array  The reordered validation messages 
    934      */ 
    935     static public function reorderMessages($class, $validation_messages) 
     932     * @param  string $class     The class to reorder messages for 
     933     * @param  array  $messages  An array of the messages 
     934     * @return array  The reordered messages 
     935     */ 
     936    static public function reorderMessages($class, $messages) 
    936937    { 
    937938        if (!isset(self::$message_orders[$class])) { 
    938             return $validation_messages; 
     939            return $messages; 
    939940        } 
    940941             
     
    944945        $other_items   = array(); 
    945946         
    946         foreach ($validation_messages as $validation_message) { 
     947        foreach ($messages as $message) { 
    947948            foreach ($matches as $num => $match_string) { 
    948                 if (fUTF8::ipos($validation_message, $match_string) !== FALSE) { 
    949                     $ordered_items[$num][] = $validation_message; 
     949                if (fUTF8::ipos($message, $match_string) !== FALSE) { 
     950                    $ordered_items[$num][] = $message; 
    950951                    continue 2; 
    951952                } 
    952953            } 
    953954             
    954             $other_items[] = $validation_message; 
     955            $other_items[] = $message; 
    955956        } 
    956957         
     
    964965     
    965966    /** 
    966      * Takes a list of validation messages and performs string and regex replacements on them 
     967     * Takes a list of messages and performs string and regex replacements on them 
    967968     *  
    968969     * @internal 
    969970     *  
    970      * @param  string $class                The class to reorder messages for 
    971      * @param  array  $validation_messages  The array of validation messages 
    972      * @return array  The new array of validation messages 
    973      */ 
    974     static public function replaceMessages($class, $validation_messages) 
     971     * @param  string $class     The class to reorder messages for 
     972     * @param  array  $messages  The array of messages 
     973     * @return array  The new array of messages 
     974     */ 
     975    static public function replaceMessages($class, $messages) 
    975976    { 
    976977        if (isset(self::$string_replacements[$class])) { 
    977             $validation_messages = str_replace( 
     978            $messages = str_replace( 
    978979                self::$string_replacements[$class]['search'], 
    979980                self::$string_replacements[$class]['replace'], 
    980                 $validation_messages   
     981                $messages  
    981982            ); 
    982983        } 
    983984         
    984985        if (isset(self::$regex_replacements[$class])) { 
    985             $validation_messages = preg_replace( 
     986            $messages = preg_replace( 
    986987                self::$regex_replacements[$class]['search'], 
    987988                self::$regex_replacements[$class]['replace'], 
    988                 $validation_messages   
    989             ); 
    990         } 
    991          
    992         return array_filter($validation_messages, array('fORMValidation', 'isNonBlankString')); 
     989                $messages  
     990            ); 
     991        } 
     992         
     993        return array_filter($messages, array('fORMValidation', 'isNonBlankString')); 
    993994    } 
    994995     
     
    10031004    static public function reset() 
    10041005    { 
    1005         self::$case_insensitive_columns             = array(); 
    1006         self::$conditional_validation_rules         = array(); 
    1007         self::$message_orders                       = array(); 
    1008         self::$one_or_more_validation_rules         = array(); 
    1009         self::$only_one_validation_rules            = array(); 
    1010         self::$regex_replacements                   = array(); 
    1011         self::$related_one_or_more_validation_rules = array(); 
    1012         self::$string_replacements                  = array(); 
    1013         self::$valid_values_validation_rules        = array(); 
     1006        self::$case_insensitive_columns  = array(); 
     1007        self::$conditional_rules         = array(); 
     1008        self::$message_orders            = array(); 
     1009        self::$one_or_more_rules         = array(); 
     1010        self::$only_one_rules            = array(); 
     1011        self::$regex_replacements        = array(); 
     1012        self::$related_one_or_more_rules = array(); 
     1013        self::$string_replacements       = array(); 
     1014        self::$valid_values_rules        = array(); 
    10141015    } 
    10151016     
     
    10471048     
    10481049    /** 
    1049      * Allows setting the order that the list items in a validation message will be displayed 
     1050     * Allows setting the order that the list items in a message will be displayed 
    10501051     * 
    10511052     * All string comparisons during the reordering process are done in a 
     
    11001101     
    11011102    /** 
    1102      * Validates values for an fActiveRecord object against the database schema and any additional validation rules that have been added 
     1103     * Validates values for an fActiveRecord object against the database schema and any additional rules that have been added 
    11031104     * 
    11041105     * @internal 
     
    11071108     * @param  array          $values      The values to validate 
    11081109     * @param  array          $old_values  The old values for the record 
    1109      * @return array  An array of validation messages 
     1110     * @return array  An array of messages 
    11101111     */ 
    11111112    static public function validate($object, $values, $old_values) 
     
    11401141        if ($message) { $validation_messages[] = $message; } 
    11411142         
    1142         foreach (self::$valid_values_validation_rules[$class] as $column => $valid_values) { 
     1143        foreach (self::$valid_values_rules[$class] as $column => $valid_values) { 
    11431144            $message = self::checkValidValuesRule($class, $values, $column, $valid_values); 
    11441145            if ($message) { $validation_messages[] = $message; } 
    11451146        } 
    11461147         
    1147         foreach (self::$conditional_validation_rules[$class] as $rule) { 
     1148        foreach (self::$conditional_rules[$class] as $rule) { 
    11481149            $messages = self::checkConditionalRule($class, $values, $rule['main_columns'], $rule['conditional_values'], $rule['conditional_columns']); 
    11491150            if ($messages) { $validation_messages = array_merge($validation_messages, $messages); } 
    11501151        } 
    11511152         
    1152         foreach (self::$one_or_more_validation_rules[$class] as $rule) { 
     1153        foreach (self::$one_or_more_rules[$class] as $rule) { 
    11531154            $message = self::checkOneOrMoreRule($class, $values, $rule['columns']); 
    11541155            if ($message) { $validation_messages[] = $message; } 
    11551156        } 
    11561157         
    1157         foreach (self::$only_one_validation_rules[$class] as $rule) { 
     1158        foreach (self::$only_one_rules[$class] as $rule) { 
    11581159            $message = self::checkOnlyOneRule($class, $values, $rule['columns']); 
    11591160            if ($message) { $validation_messages[] = $message; } 
     
    11721173     * @param  array         &$values           The values for the object 
    11731174     * @param  array         &$related_records  The related records for the object 
    1174      * @return array         An array of validation messages 
     1175     * @return array         An array of messages 
    11751176     */ 
    11761177    static public function validateRelated($object, &$values, &$related_records) 
     
    11811182        $validation_messages = array(); 
    11821183         
    1183         // Check related validation rules  
    1184         foreach (self::$related_one_or_more_validation_rules[$class] as $related_class => $routes) { 
     1184        // Check related rules  
     1185        foreach (self::$related_one_or_more_rules[$class] as $related_class => $routes) { 
    11851186            foreach ($routes as $route => $enabled) { 
    11861187                $message = self::checkRelatedOneOrMoreRule($object, $values, $related_records, $related_class, $route);