[FLOW3-general] Validation: I'm always having validation errors twice

Alexander Schnitzler mail at alexanderschnitzler.de
Thu Oct 13 18:07:25 CEST 2011


So, again problems with validation. -_-
I wrote a validator to validate a new object against some rules. Somehow 
errors that are added to the Result object are added twice and I don't 
know why.

At first my controller:

> /**
>  * @param \Acme\Users\Domain\Model\Registration|null $registration
>  * @return void
>  * @dontvalidate $registration
>  */
> public function newAccountAction(\Acme\Users\Domain\Model\Registration $registration = null) {
> 	$this->view->assign('registration', $registration);
> }
>
> /**
>  * @param \Acme\Users\Domain\Model\Registration $registration
>  * @return void
>  * @validate $registration \Acme\Users\Domain\Validator\RegistrationValidator
>  */
> public function createAccountAction(\Acme\Users\Domain\Model\Registration $registration) {
>
> }

Actually I don't know whether the newAccountAction has to be given the 
object aka null but it works. So I do not think that's part of the mistake.

So here's my \Acme\Users\Domain\Validator\RegistrationValidator validator:
> class RegistrationValidator extends \TYPO3\FLOW3\Validation\Validator\AbstractValidator {
>
>     /**
>      * @param mixed $registration
>      * @return void
>      */
> 	public function isValid($registration) {
>
>             $this->addError('Some Error', 1);
> 	}
> }

As you can see I just add one error to test the validator.

Somehow this error appears twice when debugging the validationResults.
> TYPO3\FLOW3\Error\Result
>  errors => array(empty)
>  warnings => array(empty)
>  notices => array(empty)
>  propertyResults => array(1)
>    'registration' (12) => TYPO3\FLOW3\Error\Result
>      errors => array(2)
>        integer 0 => TYPO3\FLOW3\Validation\Error
>          message => 'Some Error' (10)
>          code => integer 1
>          arguments => array(empty)
>        integer 1 => TYPO3\FLOW3\Validation\Error
>          message => 'Some Error' (10)
>          code => integer 1
>          arguments => array(empty)
>      warnings => array(empty)
>      notices => array(empty)
>      propertyResults => array(6)
> 		[...]

All other validations that are directly assigned to properties like 
"NotEmpty" are assigned just once.


Where might be the problem?
Alex


More information about the FLOW3-general mailing list