/** * Override isValid() * * Ensure that validation error messages mask password value. * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { foreach ($this->getValidators() as $validator) { if ($validator instanceof AbstractValidator) { $validator->setValueObscured(true); } } return parent::isValid($value, $context); }
/** * Is the captcha valid? * * @param mixed $value * @param mixed $context * @return boolean */ public function isValid($value, $context = null) { $this->getCaptcha()->setName($this->getName()); $belongsTo = $this->getBelongsTo(); if (empty($belongsTo) || !is_array($context)) { return parent::isValid($value, $context); } $name = $this->getFullyQualifiedName(); $root = substr($name, 0, strpos($name, '[')); $segments = substr($name, strpos($name, '[')); $segments = ltrim($segments, '['); $segments = rtrim($segments, ']'); $segments = explode('][', $segments); array_unshift($segments, $root); array_pop($segments); $newContext = $context; foreach ($segments as $segment) { if (array_key_exists($segment, $newContext)) { $newContext = $newContext[$segment]; } } return parent::isValid($value, $newContext); }
/** * Is the value provided valid? * * Autoregisters InArray validator if necessary. * * @param string $value * @param mixed $context * @return bool */ public function isValid($value, $context = null) { if ($this->registerInArrayValidator()) { if (!$this->getValidator('InArray')) { $multiOptions = $this->getMultiOptions(); $options = array(); foreach ($multiOptions as $opt_value => $opt_label) { // optgroup instead of option label if (is_array($opt_label)) { $options = array_merge($options, array_keys($opt_label)); } else { $options[] = $opt_value; } } $this->addValidator('InArray', true, array($options)); } } return parent::isValid($value, $context); }