Provides a base class for file constraint validators.

Hierarchy

Expanded class hierarchy of BaseFileConstraintValidator

File

core/modules/file/src/Plugin/Validation/Constraint/BaseFileConstraintValidator.php, line 14

Namespace

Drupal\file\Plugin\Validation\Constraint
View source
abstract class BaseFileConstraintValidator extends ConstraintValidator {

  /**
   * Checks the value is of type FileInterface.
   *
   * @param mixed $value
   *   The value to check.
   *
   * @return \Drupal\file\FileInterface
   *   The file.
   *
   * @throw Symfony\Component\Validator\Exception\UnexpectedTypeException
   *   Thrown if the value is not a FileInterface.
   */
  protected function assertValueIsFile(mixed $value) : FileInterface {
    if (!$value instanceof FileInterface) {
      throw new UnexpectedTypeException($value, FileInterface::class);
    }
    return $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BaseFileConstraintValidator::assertValueIsFile protected function Checks the value is of type FileInterface.