Feature: #104526 - Provide validators for PSR-7 UploadedFile objects in Extbase
See forge#104526
Description
4 new Extbase validators have been added to allow common validation tasks of a
PSR-7
\TYPO3\ object or an
\TYPO3\ containing PSR-7
Uploaded objects.
Note, that the new validators can only be applied to the TYPO3 implementation
of the PSR-7
\Psr\ because they validate the uploaded
files before it has been moved.
Custom implementations of the
\Uploaded must continue to
implement their own validators.
FileNameValidator
This validator ensures, that files with PHP executable file extensions can not be uploaded. The validator has no options.
FileSizeValidator
This validator can be used to validate an uploaded file against a given minimum and maximum file size.
Validator options:
minimum- The minimum size as string (e.g. 100K)maximum- The maximum size as string (e.g. 100K)
MimeTypeValidator
This validator can be used to validate an uploaded file against a given set of accepted MIME types. The validator additionally verifies, that the given file extension of the uploaded file matches allowed file extensions for the detected mime type.
Validator options:
allowed- An array of allowed MIME typesMime Types ignore- If set to "true", it is checked, the file extension check is disabledFile Extension Check
ImageDimensionsValidator
This validator can be used to validate an uploaded image for given image dimensions. The validator must only be used, when it is ensured, that the uploaded file is an image (e.g. by validating the MIME type).
Validator options:
width- Fixed width of the image as integerheight- Fixed height of the image as integermin- Minimum width of the image as integer. Default isWidth 0max- Maximum width of the image as integer. Default isWidth PHP_INT_ MAX min- Minimum height of the image as integer. Default isHeight 0max- Maximum height of the image as integer. Default isHeight PHP_INT_ MAX
Impact
TYPO3 extension autors can now use the new validators to validate a given
Uploaded object.