Search code examples
validationtypo3extbaselogical-or

Extbase disjunction validation syntax


I have a User model with a email property:

/**
 * email
 *
 * @var string
 */
protected $email = '';

I could not find any docs related to the disjunction validator annotation syntax, other than this cheat sheet: http://www.lobacher.de/files/cs/ExtbaseFluidCheatSheet_3.02_pluswerk.pdf, which does not seem to work. This is that I've tried:

@validate Disjunction(EmailAddress,NotEmpty)
@validate OR:Disjunction(0:EmailAddress,1:NotEmpty)
@validate Disjunction(0:EmailAddress,1:NotEmpty)
@validate Disjunction(0=EmailAddress,1=NotEmpty)

Solution

  • EmailAddress only throws an error if the value is set. So you do not have to specify NotEmpty at all to achieve your desired behavior.