In my entity I have the following attribute:
/**
* @var string
*
* @ORM\Column(name="programm", type="string", length=255, nullable=true)
* @Assert\File(
* maxSize = "1M",
* mimeTypes = {"application/pdf", "application/x-pdf", "image/png", "image/jpg", "image/jpeg"},
* mimeTypesMessage = "Es sind nur pdf, jpg und png Dateien erlaubt",
* groups={"new"}
* )
*/
private $programm;
and a Callback
/**
* @Assert\Callback
*/
public function validateFields(ExecutionContextInterface $context) {
if ('' == $this->programm && 2 == $this->programmextern) {
$context->buildViolation('Bitte Datei hochladen')->atPath('programm')->addViolation();
}
If the Assert\File gives an error (file too big, file doesn't have the proper mimeType, etc) I want to skip the Callback. Is there a way to access the errors produced by Assert\File in my entity, so I can trigger my Callback only if there aren't any errors?
If not, is there a way to filter errors so that, if there is more than one error, only the AssertFile error is displayed in the twig template?