get('entity')->getTarget(); if (!$target) { return; } $file = $target->getValue(); // Get the validators. $validators = $value->getUploadValidators(); // Checks that a file meets the criteria specified by the validators. if ($errors = file_validate($file, $validators)) { foreach ($errors as $error) { $this->context->addViolation($error); } } } }