Exemple #1
0
 /**
  * Validate teh element against a Joomla form Rule
  *
  * @param   string  $type   Rule type e.g. 'password'
  * @param   mixed   $value  Value to validate
  * @param   mixed   $path   Optional path to load teh rule from
  *
  * @throws Exception
  *
  * @return bool
  */
 protected function validateJRule($type, $value, $path = null)
 {
     if (!is_null($path)) {
         JFormHelper::addRulePath($path);
     }
     $rule = JFormHelper::loadRuleType($type, true);
     $xml = new SimpleXMLElement('<xml></xml>');
     $this->lang->load('com_users');
     if (!$rule->test($xml, $value)) {
         $this->validationError = '';
         foreach ($this->app->getMessageQueue() as $i => $msg) {
             if ($msg['type'] === 'warning') {
                 $this->validationError .= $msg['message'] . '<br />';
             }
         }
         FabrikWorker::killMessage($this->app, 'warning');
         return false;
     }
     return true;
 }