예제 #1
0
 /**
  * Validation data
  *
  * @param array $rules
  * @param array $data
  * @return string[]
  */
 protected function validate(array $rules, array $data)
 {
     $errors = array();
     foreach ($rules as $key => $rule) {
         if (isset($data[$key])) {
             $propertyValue = $data[$key];
             $validator = new SagepayValidator($propertyValue, $rule);
             if (!$validator->isValid()) {
                 $errors[$key] = $validator->getErrors();
             }
         }
     }
     return $errors;
 }
예제 #2
0
    /**
     * Validates values using validation rules and return the result
     *
     * @return array
     */
    public function validate()
    {
        if ($this->cardType == 'AMEX')
        {
            $this->rules['cv2'][] = array('exactLength', array(3, 4));
        }
        else
        {
            $this->rules['cv2'][] = array('exactLength', array(3));
        }

        $errors = array();
        foreach ($this->rules as $key => $rule)
        {
            $propertyValue = $this->$key;
            $validator = new SagepayValidator($propertyValue, $rule);
            if (!$validator->isValid())
            {
                $errors[$key] = $validator->getErrors();
            }
        }
        return $errors;
    }
예제 #3
0
 /**
  * Validates values using validation rules and return the result
  *
  * @return string[]
  */
 public function validate()
 {
     $errors = array();
     foreach ($this->rules as $key => $rule)
     {
         $propertyValue = $this->$key;
         $validator = new SagepayValidator($propertyValue, $rule);
         if (!$validator->isValid())
         {
             $errors[$key] = $validator->getErrors();
         }
     }
     return $errors;
 }