示例#1
0
 /**
  * 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 IfwPsn_Vendor_Zend_Validate_Abstract) {
             $validator->setObscureValue(true);
         }
     }
     return parent::isValid($value, $context);
 }
示例#2
0
文件: Multi.php 项目: jasmun/Noco100
 /**
  * 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);
 }
示例#3
0
 /**
  * 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);
 }