/** * Validates the values of the main and the reference control against each other. * * @param string $input The input of the *main* password field. * * @return bool True, in case both controls are equal, false otherwise. * * @author Christian Achatz * @version * Version 0.1, 12.09.2009<br /> */ public function validate($input) { $refValue = $this->refControl->getAttribute('value'); if ($input === $refValue) { return true; } return false; }
/** * Evaluates the regular expression that is used for filtering the * control's input. In case the developer has defined a custom * regexp it is returned instead of the default value. * * @param String $default The default filter expression. * * @return string The effective filter expression. * * @since 1.14 * @author Christian Achatz * @version * Version 0.1, 21.04.2011<br /> */ protected function getFilterExpression($default) { $expr = $this->control->getAttribute('filter-expr'); return $expr === null ? $default : $expr; }
/** * Notifies all validation listeners, who's control attribute is the same * as the name of the present control. This enables you to insert listener * tags, that output special content if notified. Hence, you can realize * special error formatting. * <p/> * In case the name of the special validator is unlike <em>null</em>, all * listeners will be notified, that have the <em>validator</em> attribute * specified. This lets you define dedicated listener, that are only * displayed when triggered by a special validator. * * @param FormControl $control The control who's listeners should be notified. * * @author Christian Achatz * @version * Version 0.1, 30.08.2009<br /> * Version 0.2, 12.02.2010 (Moved to TextFieldValidator and introduced special listener notification)<br /> */ protected function notifyValidationListeners(FormControl &$control) { $form = $control->getForm(); /* @var $listeners ValidationListenerTag[] */ $listeners = $form->getFormElementsByTagName('form:listener'); $count = count($listeners); $controlName = $control->getAttribute('name'); $validatorName = $this->getValidatorName(); for ($i = 0; $i < $count; $i++) { // Here, we're using a little trick: empty attributes are considered "null" // by the XmlParser. Thus, we can set the validator name to null to // indicate, that we want a "normal" listener (=no special listener) to be // notified! if ($listeners[$i]->getAttribute('control') === $controlName && $listeners[$i]->getAttribute('validator') === $validatorName) { $listeners[$i]->notify(); } } }
private function getMarkerClass(FormControl &$control) { $marker = $control->getAttribute(AbstractFormValidator::$CUSTOM_MARKER_CLASS_ATTRIBUTE); if (empty($marker)) { $marker = AbstractFormValidator::$DEFAULT_MARKER_CLASS; } return $marker; }