コード例 #1
0
 /**
  * @param JsonSerializationVisitor     $visitor
  * @param ConstraintViolationInterface $violation
  * @return array
  */
 public function serializeToJson(JsonSerializationVisitor $visitor, ConstraintViolationInterface $violation)
 {
     $data = array('propertyPath' => $this->transformPropertyPath($violation->getPropertyPath()), 'message' => $violation->getMessage(), 'code' => $violation->getCode(), 'value' => $violation->getInvalidValue());
     if (null === $visitor->getRoot()) {
         $visitor->setRoot($data);
     }
     return $data;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function format(Param $param, ConstraintViolationInterface $violation)
 {
     return sprintf("%s parameter %s value '%s' violated a constraint (%s)", $param instanceof QueryParam ? 'Query' : 'Request', $param->getKey(), $violation->getInvalidValue(), $violation->getMessage());
 }
コード例 #3
0
ファイル: ValidatorTrait.php プロジェクト: apitude/apitude
 /**
  * @param ConstraintViolationInterface|ConstraintViolation $error
  * @return array
  */
 private function getValidationErrorArray($error)
 {
     return ['i18nKey' => method_exists($error->getConstraint(), 'getI18nKey') ? $error->getConstraint()->getI18nKey() : get_class($error->getConstraint()), 'messageTemplate' => $error->getMessageTemplate(), 'plural' => $error->getPlural(), 'invalidValue' => $error->getInvalidValue(), 'parameters' => $error->getParameters(), 'message' => $error->getMessage(), 'path' => $error->getPropertyPath()];
 }
コード例 #4
0
 public function __construct(ConstraintViolationInterface $violation)
 {
     $this->propertyPath = $violation->getPropertyPath();
     $this->message = $violation->getMessage();
 }
コード例 #5
0
 function it_normalizes_global_violation(ConstraintViolationInterface $violation, ProductInterface $product)
 {
     $violation->getPropertyPath()->willReturn('variant.color');
     $violation->getMessage()->willReturn('Variant group already contains this color.');
     $this->normalize($violation, 'internal_api', ['product' => $product])->shouldReturn(['global' => true, 'message' => 'Variant group already contains this color.']);
 }
コード例 #6
0
 public function handle(ConstraintViolationInterface $violation, $violationTarget)
 {
     $violationTarget->addError($violation->getMessage());
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function format(ParamInterface $param, ConstraintViolationInterface $violation)
 {
     return sprintf("Parameter %s value '%s' violated a constraint (%s)", $param->getName(), $violation->getInvalidValue(), $violation->getMessage());
 }
コード例 #8
0
ファイル: ErrorHandler.php プロジェクト: ibrows/datatrans
 /**
  * @param ConstraintViolationInterface $violation
  */
 public function violation(ConstraintViolationInterface $violation)
 {
     $this->violations[] = $violation;
     $this->logger->warning("DataTrans: validation warning, '{class}', '{property}', '{message}', '{invalidValue}'!", array('content' => get_class($violation->getRoot()), 'property' => $violation->getPropertyPath(), 'message' => $violation->getMessage(), 'invalidValue' => is_scalar($violation->getInvalidValue()) ? $violation->getInvalidValue() : '_object_'));
 }
 public function throwValidationException(ConstraintViolationInterface $violation)
 {
     $exception_message = $violation->getMessage();
     throw new ValidationException($exception_message);
 }
コード例 #10
0
 /**
  * @Serializer\Groups({"all", "debug"})
  * @Serializer\SerializedName("message")
  * @Serializer\VirtualProperty
  */
 public function getMessage()
 {
     return $this->constraintViolation->getMessage();
 }