Ejemplo n.º 1
0
 /**
  * Create an API validation response from a CheckResultInterface.
  *
  * @param CheckResultInterface $result
  *
  * @throws LackOfCoffeeException
  * @return ApiResponse
  */
 public function fromCheckable(CheckResultInterface $result)
 {
     if ($result->passed()) {
         throw new LackOfCoffeeException('You are trying to send a validation error response,' . ' but your check actually passed!');
     }
     return new ApiResponse(['missing' => $result->getMissing(), 'validation' => $result->getFailed()], ApiResponse::STATUS_INVALID, ['One or more fields are invalid. Please check your input.']);
 }
 /**
  * Push an alert describing the result of a spec.
  *
  * @param CheckResultInterface $result
  */
 protected function pushValidationSpecAlert(CheckResultInterface $result)
 {
     $this->alerts->push($result->getFailed(), Alert::TYPE_VALIDATION, 'Oops...', 'alerts.spec');
 }