Exemple #1
0
 /**
  * set the locale, this is needed to update the rule
  * translations, that have been passed to the container
  * element
  *
  * @access     public
  * @param      string		new locale
  * @return     boolean
  */
 function setLocale($locale)
 {
     // rules do not store locale information
     if (!patForms::isCustomLocale($locale)) {
         return true;
     }
     $errorMessages = patForms::getCustomLocale($locale, 'Rule::' . $this->getRuleName());
     if (is_array($errorMessages)) {
         $this->validatorErrorCodes[$locale] = $errorMessages;
     }
     $this->container->addValidatorErrorCodes($this->validatorErrorCodes, $this->errorOffset);
     return true;
 }
 /**
  * Template method that applies rules and calls the elements
  * validation method
  *
  * @final
  * @access     public
  * @return     bool	$success	True on success, false otherwise
  */
 function validate()
 {
     // apply locale, if the current locale is a custom locale
     if (patForms::isCustomLocale($this->locale)) {
         $cnt = count($this->_rules);
         for ($i = 0; $i < $cnt; $i++) {
             $this->_rules[$i]['rule']->setLocale($this->locale);
         }
     }
     /**
      * validate custom rules
      */
     if (!$this->_applyRules(PATFORMS_RULE_BEFORE_VALIDATION)) {
         $this->_announce('status', 'error');
         return false;
     }
     /**
      * the the unfiltered value
      */
     $value = $this->getValue(false);
     $valid = $this->validateElement($value);
     if ($valid === false) {
         $this->_announce('status', 'error');
         return false;
     }
     /**
      * validate custom rules
      */
     if (!$this->_applyRules(PATFORMS_RULE_AFTER_VALIDATION)) {
         $this->_announce('status', 'error');
         return false;
     }
     $this->_announce('status', 'validated');
     return true;
 }