/** * Method to test if a value is valid for a field. * * @param object $field The field to validate. * @param array $values The values to validate. * @return mixed Boolean on success, JException on error. */ protected function _isValid(&$field, $values) { $result = true; // Get the validator type. if ($type = (string) $field->attributes()->validate) { // Get the validator class. $class = 'JFormRule' . $type; if (!class_exists($class)) { jimport('joomla.filesystem.path'); // Attempt to load the rule file. if ($file = JPath::find(JFormValidator::addRulePath(), $type . '.php')) { require_once $file; } if (!class_exists($class)) { return new JException(JText::sprintf('Libraries_Form_Validator_Rule_Not_Found', $type), 0, E_ERROR); } } // Run the validator. $rule = new $class(); $result = $rule->test($field, $values); } return $result; }