- Timestamp:
- 07/13/09 23:02:17 (1 year ago)
- Files:
-
- fORMValidation.php (modified) (44 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fORMValidation.php
r649 r651 Hide Line Numbers 11 11 * @link http://flourishlib.com/fORMValidation 12 12 * 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] 14 15 * @changes 1.0.0b15 Added ::addValidValuesValidationRule() [wb/jt, 2009-07-13] 15 16 * @changes 1.0.0b14 Added ::addStringReplacement() and ::addRegexReplacement() for simple validation message modification [wb, 2009-07-01] … … 31 32 { 32 33 // The following constants allow for nice looking callbacks to static methods 33 const addConditional ValidationRule = 'fORMValidation::addConditionalValidationRule';34 const addManyToMany ValidationRule = 'fORMValidation::addManyToManyValidationRule';35 const addOneOrMore ValidationRule = 'fORMValidation::addOneOrMoreValidationRule';36 const addOneToMany ValidationRule = 'fORMValidation::addOneToManyValidationRule';37 const addOnlyOne ValidationRule = 'fORMValidation::addOnlyOneValidationRule';38 const addRegexReplacement = 'fORMValidation::addRegexReplacement';39 const addStringReplacement = 'fORMValidation::addStringReplacement';40 const addValidValues ValidationRule = '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'; 49 50 50 51 … … 57 58 58 59 /** 59 * Conditional validationrules60 * Conditional rules 60 61 * 61 62 * @var array 62 63 */ 63 static private $conditional_ validation_rules = array();64 65 /** 66 * Ordering rules for validationmessages64 static private $conditional_rules = array(); 65 66 /** 67 * Ordering rules for messages 67 68 * 68 69 * @var array … … 71 72 72 73 /** 73 * One or more validationrules74 * One or more rules 74 75 * 75 76 * @var array 76 77 */ 77 static private $one_or_more_ validation_rules = array();78 79 /** 80 * Only one validationrules78 static private $one_or_more_rules = array(); 79 80 /** 81 * Only one rules 81 82 * 82 83 * @var array 83 84 */ 84 static private $only_one_ validation_rules = array();85 86 /** 87 * Regular expression replacements performed on each validationmessage85 static private $only_one_rules = array(); 86 87 /** 88 * Regular expression replacements performed on each message 88 89 * 89 90 * @var array … … 92 93 93 94 /** 94 * Validation rules that require at least one or more *-to-many related records to be associated95 * Rules that require at least one or more *-to-many related records to be associated 95 96 * 96 97 * @var array 97 98 */ 98 static private $related_one_or_more_ validation_rules = array();99 100 /** 101 * String replacements performed on each validationmessage99 static private $related_one_or_more_rules = array(); 100 101 /** 102 * String replacements performed on each message 102 103 * 103 104 * @var array … … 106 107 107 108 /** 108 * Valid values validationrules109 * Valid values rules 109 110 * 110 111 * @var array 111 112 */ 112 static private $valid_values_ validation_rules = array();113 114 115 /** 116 * Adds a conditional validationrule113 static private $valid_values_rules = array(); 114 115 116 /** 117 * Adds a conditional rule 117 118 * 118 119 * If a non-empty value is found in one of the `$main_columns`, or if … … 120 121 * `$conditional_columns` will also be required to have a value. 121 122 * 122 * @param mixed $class The class name or instance of the class this validationrule applies to123 * @param mixed $class The class name or instance of the class this rule applies to 123 124 * @param string|array $main_columns The column(s) to check for a value 124 125 * @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 … … 126 127 * @return void 127 128 */ 128 static public function addConditional ValidationRule($class, $main_columns, $conditional_values, $conditional_columns)129 static public function addConditionalRule($class, $main_columns, $conditional_values, $conditional_columns) 129 130 { 130 131 $class = fORM::getClass($class); 131 132 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(); 134 135 } 135 136 … … 145 146 $rule['conditional_columns'] = $conditional_columns; 146 147 147 self::$conditional_ validation_rules[$class][] = $rule;148 } 149 150 151 /** 152 * Add a many-to-many validationrule that requires at least one related record is associated with the current record148 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 153 154 * 154 155 * @param mixed $class The class name or instance of the class to add the rule for … … 157 158 * @return void 158 159 */ 159 static public function addManyToMany ValidationRule($class, $related_class, $route=NULL)160 static public function addManyToManyRule($class, $related_class, $route=NULL) 160 161 { 161 162 $class = fORM::getClass($class); 162 163 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(); 169 170 } 170 171 … … 176 177 ); 177 178 178 self::$related_one_or_more_ validation_rules[$class][$related_class][$route] = TRUE;179 } 180 181 182 /** 183 * Adds a one-or-more validationrule that requires at least one of the columns specified has a value179 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 184 185 * 185 186 * @param mixed $class The class name or instance of the class the columns exists in … … 187 188 * @return void 188 189 */ 189 static public function addOneOrMore ValidationRule($class, $columns)190 static public function addOneOrMoreRule($class, $columns) 190 191 { 191 192 $class = fORM::getClass($class); … … 193 194 settype($columns, 'array'); 194 195 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(); 197 198 } 198 199 … … 200 201 $rule['columns'] = $columns; 201 202 202 self::$one_or_more_ validation_rules[$class][] = $rule;203 } 204 205 206 /** 207 * Add a one-to-many validationrule that requires at least one related record is associated with the current record203 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 208 209 * 209 210 * @param mixed $class The class name or instance of the class to add the rule for … … 212 213 * @return void 213 214 */ 214 static public function addOneToMany ValidationRule($class, $related_class, $route=NULL)215 static public function addOneToManyRule($class, $related_class, $route=NULL) 215 216 { 216 217 $class = fORM::getClass($class); 217 218 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(); 224 225 } 225 226 … … 231 232 ); 232 233 233 self::$related_one_or_more_ validation_rules[$class][$related_class][$route] = TRUE;234 } 235 236 237 /** 238 * Add an only-one validationrule that requires exactly one of the columns must have a value234 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 239 240 * 240 241 * @param mixed $class The class name or instance of the class the columns exists in … … 242 243 * @return void 243 244 */ 244 static public function addOnlyOne ValidationRule($class, $columns)245 static public function addOnlyOneRule($class, $columns) 245 246 { 246 247 $class = fORM::getClass($class); … … 248 249 settype($columns, 'array'); 249 250 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(); 252 253 } 253 254 … … 255 256 $rule['columns'] = $columns; 256 257 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 validationmessage258 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 263 264 * 264 265 * Regex replacement is done after the `post::validate()` hook, and right 265 * before the validationmessages are reordered.266 * 267 * If a validationmessage is an empty string after replacement, it will be268 * removed from the list of validationmessages.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. 269 270 * 270 271 * @param mixed $class The class name or instance of the class the columns exists in … … 290 291 291 292 /** 292 * Adds a call to [http://php.net/str_replace `str_replace()`] for each validationmessage293 * Adds a call to [http://php.net/str_replace `str_replace()`] for each message 293 294 * 294 295 * String replacement is done after the `post::validate()` hook, and right 295 * before the validationmessages are reordered.296 * 297 * If a validationmessage is an empty string after replacement, it will be298 * removed from the list of validationmessages.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. 299 300 * 300 301 * @param mixed $class The class name or instance of the class the columns exists in … … 328 329 * on the column in the database, or using a MySQL `ENUM` data type. 329 330 * 330 * @param mixed $class The class name or instance of the class this validationrule applies to331 * @param mixed $class The class name or instance of the class this rule applies to 331 332 * @param string $column The column to validate 332 333 * @param array $valid_values The valid values to check - `NULL` values are always allows if the column is not set to `NOT NULL` 333 334 * @return void 334 335 */ 335 static public function addValidValues ValidationRule($class, $column, $valid_values)336 static public function addValidValuesRule($class, $column, $valid_values) 336 337 { 337 338 $class = fORM::getClass($class); 338 339 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(); 341 342 } 342 343 343 344 settype($valid_values, 'array'); 344 345 345 self::$valid_values_ validation_rules[$class][$column] = $valid_values;346 self::$valid_values_rules[$class][$column] = $valid_values; 346 347 347 348 fORM::registerInspectCallback($class, $column, self::inspect); … … 356 357 * @param array &$values An associative array of all values going into the row (needs all for multi-field unique constraint checking) 357 358 * @param array &$old_values The old values from the record 358 * @return string A validation error message for the column specified359 * @return string An error message for the column specified 359 360 */ 360 361 static private function checkAgainstSchema($object, $column, &$values, &$old_values) … … 408 409 409 410 /** 410 * Validates against a conditional validationrule411 * 412 * @param string $class The class this validationrule applies to411 * Validates against a conditional rule 412 * 413 * @param string $class The class this rule applies to 413 414 * @param array &$values An associative array of all values for the record 414 415 * @param array $main_columns The columns to check for a value 415 416 * @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 416 417 * @param array $conditional_columns The columns that are to be required 417 * @return array The validationerror messages for the rule specified418 * @return array The error messages for the rule specified 418 419 */ 419 420 static private function checkConditionalRule($class, &$values, $main_columns, $conditional_values, $conditional_columns) … … 454 455 * @param string $column The column to check 455 456 * @param mixed $value The value to check 456 * @return string A validation error message for the column specified457 * @return string An error message for the column specified 457 458 */ 458 459 static private function checkDataType($class, $column, $value) … … 525 526 * @param string $column The column to check 526 527 * @param array &$values The values to check 527 * @return string A validation error message for the column specified528 * @return string An error message for the column specified 528 529 */ 529 530 static private function checkForeignKeyConstraints($class, $column, &$values) … … 559 560 560 561 /** 561 * Validates against a one-or-more validationrule562 * Validates against a one-or-more rule 562 563 * 563 564 * @param string $class The class the columns are part of 564 565 * @param array &$values An associative array of all values for the record 565 566 * @param array $columns The columns to check 566 * @return string A validation error message for the rule567 * @return string An error message for the rule 567 568 */ 568 569 static private function checkOneOrMoreRule($class, &$values, $columns) … … 591 592 592 593 /** 593 * Validates against an only-one validationrule594 * Validates against an only-one rule 594 595 * 595 596 * @param string $class The class the columns are part of 596 597 * @param array &$values An associative array of all values for the record 597 598 * @param array $columns The columns to check 598 * @return string A validation error message for the rule599 * @return string An error message for the rule 599 600 */ 600 601 static private function checkOnlyOneRule($class, &$values, $columns) … … 635 636 * @param array &$values An associative array of all values going into the row (needs all for multi-field unique constraint checking) 636 637 * @param array &$old_values The old values for the record 637 * @return string A validation error message638 * @return string An error message 638 639 */ 639 640 static private function checkPrimaryKeys($object, &$values, &$old_values) … … 703 704 704 705 /** 705 * Validates against a *-to-many one or more validationrule706 * Validates against a *-to-many one or more rule 706 707 * 707 708 * @param fActiveRecord $object The object being checked … … 710 711 * @param string $related_class The name of the related class 711 712 * @param string $route The name of the route from the class to the related class 712 * @return string A validation error message for the rule713 * @return string An error message for the rule 713 714 */ 714 715 static private function checkRelatedOneOrMoreRule($object, &$values, &$related_records, $related_class, $route) … … 742 743 * @param array &$values The values to check 743 744 * @param array &$old_values The old values for the record 744 * @return string A validation error message for the unique constraints745 * @return string An error message for the unique constraints 745 746 */ 746 747 static private function checkUniqueConstraints($object, &$values, &$old_values) … … 814 815 815 816 /** 816 * Validates against a valid values validationrule817 * 818 * @param string $class The class this validationrule applies to817 * Validates against a valid values rule 818 * 819 * @param string $class The class this rule applies to 819 820 * @param array &$values An associative array of all values for the record 820 821 * @param string $column The column the rule applies to 821 822 * @param array $valid_values An array of valid values to check the column against 822 * @return string The validationerror message for the rule specified823 * @return string The error message for the rule specified 823 824 */ 824 825 static private function checkValidValuesRule($class, &$values, $column, $valid_values) … … 871 872 static private function initializeRuleArrays($class) 872 873 { 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(); 878 879 } 879 880 … … 891 892 static public function inspect($class, $column, &$metadata) 892 893 { 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]; 895 896 } 896 897 } … … 929 930 * @internal 930 931 * 931 * @param string $class The class to reorder messages for932 * @param array $ validation_messages An array of the validationmessages933 * @return array The reordered validationmessages934 */ 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) 936 937 { 937 938 if (!isset(self::$message_orders[$class])) { 938 return $ validation_messages;939 return $messages; 939 940 } 940 941 … … 944 945 $other_items = array(); 945 946 946 foreach ($ validation_messages as $validation_message) {947 foreach ($messages as $message) { 947 948 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; 950 951 continue 2; 951 952 } 952 953 } 953 954 954 $other_items[] = $ validation_message;955 $other_items[] = $message; 955 956 } 956 957 … … 964 965 965 966 /** 966 * Takes a list of validationmessages and performs string and regex replacements on them967 * Takes a list of messages and performs string and regex replacements on them 967 968 * 968 969 * @internal 969 970 * 970 * @param string $class The class to reorder messages for971 * @param array $ validation_messages The array of validationmessages972 * @return array The new array of validationmessages973 */ 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) 975 976 { 976 977 if (isset(self::$string_replacements[$class])) { 977 $ validation_messages = str_replace(978 $messages = str_replace( 978 979 self::$string_replacements[$class]['search'], 979 980 self::$string_replacements[$class]['replace'], 980 $ validation_messages981 $messages 981 982 ); 982 983 } 983 984 984 985 if (isset(self::$regex_replacements[$class])) { 985 $ validation_messages = preg_replace(986 $messages = preg_replace( 986 987 self::$regex_replacements[$class]['search'], 987 988 self::$regex_replacements[$class]['replace'], 988 $ validation_messages989 ); 990 } 991 992 return array_filter($ validation_messages, array('fORMValidation', 'isNonBlankString'));989 $messages 990 ); 991 } 992 993 return array_filter($messages, array('fORMValidation', 'isNonBlankString')); 993 994 } 994 995 … … 1003 1004 static public function reset() 1004 1005 { 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(); 1014 1015 } 1015 1016 … … 1047 1048 1048 1049 /** 1049 * Allows setting the order that the list items in a validationmessage will be displayed1050 * Allows setting the order that the list items in a message will be displayed 1050 1051 * 1051 1052 * All string comparisons during the reordering process are done in a … … 1100 1101 1101 1102 /** 1102 * Validates values for an fActiveRecord object against the database schema and any additional validationrules that have been added1103 * Validates values for an fActiveRecord object against the database schema and any additional rules that have been added 1103 1104 * 1104 1105 * @internal … … 1107 1108 * @param array $values The values to validate 1108 1109 * @param array $old_values The old values for the record 1109 * @return array An array of validationmessages1110 * @return array An array of messages 1110 1111 */ 1111 1112 static public function validate($object, $values, $old_values) … … 1140 1141 if ($message) { $validation_messages[] = $message; } 1141 1142 1142 foreach (self::$valid_values_ validation_rules[$class] as $column => $valid_values) {1143 foreach (self::$valid_values_rules[$class] as $column => $valid_values) { 1143 1144 $message = self::checkValidValuesRule($class, $values, $column, $valid_values); 1144 1145 if ($message) { $validation_messages[] = $message; } 1145 1146 } 1146 1147 1147 foreach (self::$conditional_ validation_rules[$class] as $rule) {1148 foreach (self::$conditional_rules[$class] as $rule) { 1148 1149 $messages = self::checkConditionalRule($class, $values, $rule['main_columns'], $rule['conditional_values'], $rule['conditional_columns']); 1149 1150 if ($messages) { $validation_messages = array_merge($validation_messages, $messages); } 1150 1151 } 1151 1152 1152 foreach (self::$one_or_more_ validation_rules[$class] as $rule) {1153 foreach (self::$one_or_more_rules[$class] as $rule) { 1153 1154 $message = self::checkOneOrMoreRule($class, $values, $rule['columns']); 1154 1155 if ($message) { $validation_messages[] = $message; } 1155 1156 } 1156 1157 1157 foreach (self::$only_one_ validation_rules[$class] as $rule) {1158 foreach (self::$only_one_rules[$class] as $rule) { 1158 1159 $message = self::checkOnlyOneRule($class, $values, $rule['columns']); 1159 1160 if ($message) { $validation_messages[] = $message; } … … 1172 1173 * @param array &$values The values for the object 1173 1174 * @param array &$related_records The related records for the object 1174 * @return array An array of validationmessages1175 * @return array An array of messages 1175 1176 */ 1176 1177 static public function validateRelated($object, &$values, &$related_records) … … 1181 1182 $validation_messages = array(); 1182 1183 1183 // Check related validationrules1184 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) { 1185 1186 foreach ($routes as $route => $enabled) { 1186 1187 $message = self::checkRelatedOneOrMoreRule($object, $values, $related_records, $related_class, $route);
