[Flow] Validation > Exception instead of going back to newAction

Stephen Bungert stephenbungert at yahoo.de
Fri Dec 6 11:24:01 CET 2013


This is a validator that makes sure entities are unique

https://git.typo3.org/Packages/TYPO3.Flow.git/blob/master:/Classes/TYPO3/Flow/Validation/Validator/UniqueEntityValidator.php

I use a modified version of it to make sure my user models don't have an 
already used email address, amongst other things.

You add the annotation to the controller action, something like this:


 /**
  * Updates a user profile.
  *
  * @Flow\Validate(argumentName="$user", 
type="\Vendor\Package\Validation\Validator\UniqueEntityValidator", 
options={"identityProperties"={"email"})
  * @param \Vendor\Package\Domain\Model\User\User $user A new user to 
update.
  * @return void
  */
 public function profileUpdateAction(\Vendor\Package\Domain\Model\User\User 
$user) {

You get access to the whole object not just a  property, so maybe you could 
use your build date method in the validator to if the date and time 
properties are valid. 




More information about the Flow mailing list