/** * @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; }
/** * {@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()); }
/** * @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()]; }
public function __construct(ConstraintViolationInterface $violation) { $this->propertyPath = $violation->getPropertyPath(); $this->message = $violation->getMessage(); }
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.']); }
public function handle(ConstraintViolationInterface $violation, $violationTarget) { $violationTarget->addError($violation->getMessage()); }
/** * {@inheritdoc} */ public function format(ParamInterface $param, ConstraintViolationInterface $violation) { return sprintf("Parameter %s value '%s' violated a constraint (%s)", $param->getName(), $violation->getInvalidValue(), $violation->getMessage()); }
/** * @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); }
/** * @Serializer\Groups({"all", "debug"}) * @Serializer\SerializedName("message") * @Serializer\VirtualProperty */ public function getMessage() { return $this->constraintViolation->getMessage(); }