class BaseFileConstraintValidator
Provides a base class for file constraint validators.
Hierarchy
- class \Drupal\file\Plugin\Validation\Constraint\BaseFileConstraintValidator extends \Symfony\Component\Validator\ConstraintValidator
 
Expanded class hierarchy of BaseFileConstraintValidator
File
- 
              core/
modules/ file/ src/ Plugin/ Validation/ Constraint/ BaseFileConstraintValidator.php, line 14  
Namespace
Drupal\file\Plugin\Validation\ConstraintView 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
| Title Sort descending | Modifiers | Object type | Summary | 
|---|---|---|---|
| BaseFileConstraintValidator::assertValueIsFile | protected | function | Checks the value is of type FileInterface. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.