예제 #1
0
 /**
  * Fail each field individually
  *
  * @param array $valid
  * @param array $invalid
  * @param Validator $validator
  */
 protected function failEachOnce($valid, $invalid, Validator $validator)
 {
     foreach ($invalid as $field => $value) {
         $data = array_except($valid, $field);
         $data[$field] = $value;
         $this->assertFalse($validator->validate($data), $field . ': ' . print_r($value, true));
         $this->assertTrue($validator->getMessages()->has($field), $field . ' should fail');
     }
 }
예제 #2
0
 /**
  * Run a sub-validator and merge messages into the error messages
  *
  * @param Validator $validator
  * @param $values
  * @param $key
  *
  * @return bool
  */
 protected function subValidate(Validator $validator, $values, $key)
 {
     if ($validator->validate($values)) {
         return true;
     }
     $this->getMessages()->merge($validator->getMessages());
     $this->addErrorMessage($key, 'There was an error with the  subset of data');
     return false;
 }