Changeset 1412
- Timestamp:
- 12/08/06 04:35:31 (2 years ago)
- Location:
- branches/0.11/src/validator
- Files:
-
- 2 modified
-
AgaviBaseFileValidator.class.php (modified) (1 diff)
-
AgaviValidator.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.11/src/validator/AgaviBaseFileValidator.class.php
r1389 r1412 109 109 return true; 110 110 } 111 112 /** 113 * Returns all available keys in the currently set base. 114 * 115 * @return array The available keys. 116 * 117 * @author Dominik del Bondio <ddb@bitxtender.com 118 * @since 0.11.0 119 */ 120 protected function getKeysInCurrentBase() 121 { 122 $files = $this->getContext()->getRequest()->getFiles(); 123 $array = array(); 124 foreach($files as $name => $file) { 125 $array[$name] = $file['name']; 126 } 127 128 $names = $this->curBase->getValue($array, array()); 129 return array_keys($names); 130 } 131 111 132 } 112 133 -
branches/0.11/src/validator/AgaviValidator.class.php
r1397 r1412 576 576 * names 577 577 */ 578 $array = $this->validationParameters->getParameters(); 579 $names = $this->curBase->getValue($array, array()); 578 $names = $this->getKeysInCurrentBase(); 579 580 // if the names array is empty this means we need to throw an error since 581 // this means the input doesn't exist 582 if(count($names) == 0) { 583 if($this->getParameter('required', true)) { 584 $this->throwError(); 585 return self::mapErrorCode($this->getParameter('severity', 'error')); 586 } else { 587 // no reason to throw any error since it wouldn't be included anyways 588 return self::NONE; 589 } 590 } 580 591 581 592 // throw the wildcard away … … 585 596 586 597 // validate in every name defined in the request 587 foreach( array_keys($names)as $name) {598 foreach($names as $name) { 588 599 $t = $this->validateInBase($base->pushRetNew($name)); 589 600 … … 654 665 } 655 666 667 668 /** 669 * Returns all available keys in the currently set base. 670 * 671 * @return array The available keys. 672 * 673 * @author Dominik del Bondio <ddb@bitxtender.com 674 * @since 0.11.0 675 */ 676 protected function getKeysInCurrentBase() 677 { 678 $array = $this->validationParameters->getParameters(); 679 $names = $this->curBase->getValue($array, array()); 680 681 return array_keys($names); 682 } 683 656 684 } 657 685

