/** * ValidationException constructor. * * @param IValidationResult $validationResult * @param null $message */ public function __construct(IValidationResult $validationResult, $message = null) { $this->validationResult = $validationResult; $data = ['errors' => ['validation' => $validationResult->toArray()]]; $response = new JsonResponse(HttpStatusCode::UNPROCESSABLE_ENTITY, $data); parent::__construct($response, $message); }
/** * @param IValidationResult $result * * @return array */ protected function getNullableSubjects(IValidationResult $result) { $nullableSubjects = []; foreach ($result->getErrors() as $error) { if ($error->getConstraint() instanceof NullableConstraint) { $nullableSubjects[] = $error->getSubject(); } } return $nullableSubjects; }