[FLOW3-general] Re: Validate if an object is unique

Widmer Cornel cornel at kollerinternet.ch
Thu Feb 28 14:54:34 CET 2013


Hi Bastian

In my case I havent to set the annotation "options={"identityProperties"={"emailAddress"}}". It worked only with the annotation in my model and the validation in the controller. So is there something to be aware of?

MODEL:
/**
 * @var string
 * @Flow\Identity
 * @Flow\Validate(type="NotEmpty")
 * @Flow\Validate(type="EmailAddress")
 */
protected $emailBusiness;

------------

CONTROLLER:
/**
 * update action
 *
 * @param \WS\Rico\Domain\Model\User $updateUser
 * @Flow\Validate(argumentName="updateUser", type="UniqueEntity")
 *
 * @param array $password
 * @Flow\Validate(argumentName="password", type="\WS\Rico\Validation\Validator\PasswordValidator", options={"dontCheck"="ifEmpty","minimumLength"=3})
 *
 * @return void
 */



Quote: Bastian Waidelich wrote on Thu, 28 February 2013 14:15
----------------------------------------------------
> Widmer Cornel wrote:
> 
> Hi,
> > I tried to validate on the controller-action with "UniqueEntity" but
> > then i got the error: "The object supplied for the UniqueEntityValidator
> > must have at least one identity property."
> 
> 
> If you look at the code of the UniqueEntityValidator (which is 
> always a good idea btw) you can see that the exception is only thrown if 
> the Entity doesn't contain properties marked as @ORM\Identity *and* the 
> "identityProperties" option is not specified.
> 
> Try
> 
> @Flow\Validate(argumentName="$user", type="UniqueEntity", 
> options={"identityProperties"={"emailAddress"}})
> 
> 
> 
> http://git.typo3.org/FLOW3/Packages/TYPO3.FLOW3.git/blob/master:/Classes/TYPO3/Flow/Validation/Validator/UniqueEntityValidator.php
> 
> 
> -- 
> Bastian Waidelich
> --
> Core Developer Team
> 
> TYPO3 .... inspiring people to share!
> Get involved: typo3.org
----------------------------------------------------




More information about the FLOW3-general mailing list