Search code examples
annotationsdoctrinetypo3

How to replace typo3 deprecated Annotation @validate Boolean(is=true)?


I have to upgrade a Typo3 v9 project to Typo3 v10.

Annotations like they were before are deprecated. I know how to replace something like @validate NotEmpty with @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")

But I have some classes that use @validate Boolean(is=true)

As far as I can tell it means that the Checkbox of a form has to be checked and the validation is done in the model.

Can anyone please tell me how to replace this? Otherwise I think I have to code the validation in my controller class


Solution

  • You need to use options for this:

    /**
     * @TYPO3\CMS\Extbase\Annotation\Validate("Boolean", options={"is": true})
     */
    public bool $enabled;
    

    See Validating in the domain model with annotations