diff --git a/src/Plugin/EntityBrowser/WidgetValidation/File.php b/src/Plugin/EntityBrowser/WidgetValidation/File.php index c5e48c8..6399fc2 100644 --- a/src/Plugin/EntityBrowser/WidgetValidation/File.php +++ b/src/Plugin/EntityBrowser/WidgetValidation/File.php @@ -27,11 +27,15 @@ public function validate(array $entities, array $options = []) { // in mind. foreach ($entities as $entity) { if (isset($options['validators'])) { - // Checks that a file meets the criteria specified by the validators. - if ($errors = file_validate($entity, $options['validators'])) { - foreach ($errors as $error) { - $violation = new ConstraintViolation($error, $error, [], $entity, '', $entity); - $violations->add($violation); + // Make sure that only files are validated. + // @see https://www.drupal.org/project/entity_browser/issues/3122383 + if (in_array('Drupal\file\FileInterface', class_implements($entity))) { + // Checks that a file meets the criteria specified by the validators. + if ($errors = file_validate($entity, $options['validators'])) { + foreach ($errors as $error) { + $violation = new ConstraintViolation($error, $error, [], $entity, '', $entity); + $violations->add($violation); + } } } }