class BaseFileConstraintValidator
Provides a base class for file constraint validators.
Hierarchy
- class \Symfony\Component\Validator\ConstraintValidator implements \Symfony\Component\Validator\ConstraintValidatorInterface
- 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 | Overriden Title | Overrides |
---|---|---|---|---|---|
BaseFileConstraintValidator::assertValueIsFile | protected | function | Checks the value is of type FileInterface. | ||
ConstraintValidator::$context | protected | property | |||
ConstraintValidator::formatTypeOf | protected | function | Returns a string representation of the type of the value. | ||
ConstraintValidator::formatValue | protected | function | Returns a string representation of the value. | ||
ConstraintValidator::formatValues | protected | function | Returns a string representation of a list of values. | ||
ConstraintValidator::initialize | public | function | Initializes the constraint validator. | Overrides ConstraintValidatorInterface::initialize | |
ConstraintValidator::OBJECT_TO_STRING | public | constant | Whether to cast objects with a "__toString()" method to strings. | ||
ConstraintValidator::PRETTY_DATE | public | constant | Whether to format {@link \DateTime} objects, either with the {@link \IntlDateFormatter} (if it is available) or as RFC-3339 dates ("Y-m-d H:i:s"). |
||
ConstraintValidatorInterface::validate | public | function | Checks if the passed value is valid. | 119 |