Example #1
0
 /**
  * Runs validation in a hash object that may or may
  * not be the result of request->data(), but has the same
  * format.
  * @return boolean True if validation passed
  */
 public function validate(array $requestData)
 {
     $ourData = Hash::extract($requestData, $this->getInputName());
     foreach ($this->getAttributeNames() as $name) {
         $validations = $this->extractNormalizedValidations($name);
         foreach ($validations as $validationKey => $validatorConfig) {
             $validator = Validator::factory($validationKey);
             $validator->configure($validatorConfig);
             $validator->init();
             if (!array_key_exists($name, $ourData) || !$validator->test($ourData[$name], $this)) {
                 $this->setValidationError($name, $validationKey, $validator->getMessage());
             }
         }
     }
     return !$this->hasValidationErrors();
 }
 /**
  * {@inheritdoc}
  */
 public function applyOptions(array $args)
 {
     $this->keyword = $args[0];
     $this->classname = Validator::generateClassName($this->keyword);
 }