Esempio n. 1
0
 function tearDown()
 {
     $this->_config = null;
     Piece_Right_Error::clearErrors();
     Piece_Right_Error::popCallback();
 }
Esempio n. 2
0
 /**
  * Validates a field value by the given validations.
  *
  * @param string  $fieldName
  * @param string  $value
  * @param boolean $isFinals
  * @throws PIECE_RIGHT_ERROR_NOT_FOUND
  * @throws PIECE_RIGHT_ERROR_INVALID_VALIDATOR
  * @throws PIECE_RIGHT_ERROR_CANNOT_READ
  * @throws PIECE_RIGHT_ERROR_NOT_READABLE
  * @since Method available since Release 0.3.0
  */
 function _validateField($fieldName, $value, $isFinals)
 {
     foreach ($this->_config->getValidations($fieldName) as $validation) {
         if ($validation['useInFinals'] != $isFinals) {
             continue;
         }
         $validator =& Piece_Right_Validator_Factory::factory($validation['validator']);
         if (Piece_Right_Error::hasErrors('exception')) {
             return;
         }
         if (is_array($value) && !$validator->isArrayable()) {
             Piece_Right_Error::pushCallback(create_function('$error', 'return ' . PEAR_ERRORSTACK_PUSHANDLOG . ';'));
             Piece_Right_Error::push(PIECE_RIGHT_ERROR_NOT_ARRAYABLE, "The value of the field [ {$fieldName} ] is an array, but the validator [ {$validation['validator']} ] is not arrayable. This validation is skipped.", 'warning');
             Piece_Right_Error::popCallback();
             $this->_results->addError($fieldName, $validation['validator'], $validator->getMessage());
             continue;
         }
         $validator->setResults($this->_results);
         $validator->setRules($validation['rules']);
         $validator->setMessage($validation['message']);
         $validator->setPayload($this->_payload);
         if (!$validator->validate($value)) {
             $this->_results->addError($fieldName, $validation['validator'], $validator->getMessage());
         }
     }
 }
Esempio n. 3
0
 /**
  * Enables the last callback.
  *
  * @since Method available since Release 1.10.0
  */
 function enableCallback()
 {
     Piece_Right_Error::popCallback();
 }
Esempio n. 4
0
 function tearDown()
 {
     foreach (array_keys($_POST) as $field) {
         unset($_POST[$field]);
     }
     unset($_SERVER['REQUEST_METHOD']);
     Piece_Right_Validator_Factory::clearInstances();
     $GLOBALS['PIECE_RIGHT_Validator_Directories'] = $this->_oldValidatorDirectories;
     Piece_Right_Filter_Factory::clearInstances();
     $GLOBALS['PIECE_RIGHT_Filter_Directories'] = $this->_oldFilterDirectories;
     $cache =& new Cache_Lite_File(array('cacheDir' => "{$this->_cacheDirectory}/", 'masterFile' => '', 'automaticSerialization' => true, 'errorHandlingAPIBreak' => true));
     $cache->clean();
     Piece_Right_Error::clearErrors();
     Piece_Right_Error::popCallback();
 }