Validate image size/type after upload via f:form.upload

Hi everyone,

I’m a bit stuck with one task. I want to validate an uploaded image if the size and type are okay.
The upload, storing, … is working perfect. So the last piece what is missing, is the validation.

In my html code I’m using:

`````<f:form.upload name=“teaserImage” id=“teaserImageInput” collection=“persistentUGC” />`

Now I thought I check the argument in my action and use the media validators for type and size like this:

 * @param Package $package
 * @param \TYPO3\Flow\Resource\Resource $teaserImage
 * @Flow\Validate("$teaserImage", type="\TYPO3\Media\Validator\ImageSizeValidator", options={ "minimumWidth"=150})
 * @Flow\Validate("$teaserImage", type="\TYPO3\Media\Validator\ImageTypeValidator", options={ "allowedTypes"={"jpeg", "png"} })
 * @return void
public function updateAction(Package $package, $teaserImage = null) {
    if($teaserImage !== null) {
        $image = new Image($teaserImage);


Okay, I read that the $teaserImage has to be of type \TYPO3\Media\Domain\Model\ImageInterface and because the image which is coming is defined as Resource this doesn’t work. If I’m changing the param for teaser image to ImageInterface I get the error message:
You need to use $propertyMappingConfiguration->allowProperties('__collectionName') to enable mapping of this property.

So now I’m a lost…

Am I even on the right direction?

Thank you for your help!