[FLOW3-general] Howto: Validation (Base Model and Supplemental)?

Alexander Schnitzler mail at alexanderschnitzler.de
Thu Oct 13 16:44:46 CEST 2011


Actually I wrote a blogpost as well some time ago. It's been for Extbase 
but shows the problem I am facing.

> http://www.alexanderschnitzler.de/2011/06/error-handling-with-extbase-writing-own-validators/

In my case I am passing the whole object into the validator, not just a 
string, array or object-property.

> /**
>  * @param Tx_ExtensionName_Domain_Model_ModelName $newObject
>  * @validate $newObject Tx_ExtensionName_Domain_Validator_ValidatorName
>  */
> public function createAction(Tx_ExtensionName_Domain_Model_ModelName $newObject)
> {
>     $this->modelNameRepository->add($newObject);
> }

Well, probably I just wrote something wrong but as the validation of 
properties succeeded in my case and the validation of the whole model 
didn't I first thought about an error of concept.


Am 13.10.2011 16:35, schrieb Thomas Layh:
> I wrote this stuff down in a tutorial some time ago. It is possible that it
> is a little bit outdated, but perhaps it helps anyway.
> http://www.layh.com/work/flow3-fluid/tutorials/flow3-password-validator.html
>
> Greetings,
> Thomas
>
>
> On Thu, Oct 13, 2011 at 16:28, Thomas Layh<thomas at layh.com>  wrote:
>
>> Hi,
>>
>> I a not completely sure but I think what you want to do is to validate your
>> registration array or whatever it is.
>>
>> I wrote a passsowrd validator some time ago and the way I used the
>> annotations looked like that:
>>
>> * @param array $password
>>   * @validate $password
>> \Layh\Events\Validation\Validator\PasswordValidator(minimumLength = 3)
>>
>> So in your case the line for the validation could look like:
>>
>> @validate $registration \Acme\Users\Domain\Validator\RegistrationValidator
>>
>> Perhaps it helps.
>>
>> Greetings,
>> Thomas
>>
>>
>>
>>
>> On Thu, Oct 13, 2011 at 16:14, Alexander Schnitzler<
>> mail at alexanderschnitzler.de>  wrote:
>>
>>> Hey folks,
>>> in the manual there is a part about validation, since today I guess.
>>> http://flow3.typo3.org/**fileadmin/manual/nightly/**
>>> TheDefinitiveGuide/PartII/**Validation.html<
>> http://flow3.typo3.org/fileadmin/manual/nightly/TheDefinitiveGuide/PartII/Validation.html
>>>
>>>
>>> There it says:
>>>
>>>> Base model and supplemental rules are not covered by this tutorial.
>>>>
>>>
>>> Alright, I tried using my own validator, validating a whole model.
>>>
>>>   /**
>>>>   * @param mixed $registration
>>>>   * @return void
>>>>   * @validate \Acme\Users\Domain\Validator\**RegistrationValidator
>>>>   */
>>>> public function createAccountAction($**registration) {
>>>>   // something here
>>>> }
>>>>
>>>
>>>
>>> Being familiar with extbase I hoped that would work fine, but an
>> exception
>>> is thrown.
>>>
>>>   TYPO3\FLOW3\Error\**ErrorHandler::handleError(8, "Undefined index:
>>>> argumentName",
>> "/var/www/public_html/FLOW3/**Data/Temporary/Developm…O3_*
>>>> *FLOW3_Validation_**ValidatorResolver_Original.**php", 199, array)
>>>>
>>>
>>> I guess this is because validators only work for model arguments (yet?),
>>> don't they? Differs the way of validating whole models from the one in
>>> Extbase? Is there a tutorial for that or do I just have to validate
>> without
>>> a validator class inside the controller?
>>>
>>> Anyone having an answer to this?
>>>
>>> Kind regards!
>>> Alex
>>> ______________________________**_________________
>>> FLOW3-general mailing list
>>> FLOW3-general at lists.typo3.org
>>> http://lists.typo3.org/cgi-**bin/mailman/listinfo/flow3-**general<
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general>
>> _______________________________________________
>> FLOW3-general mailing list
>> FLOW3-general at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>



More information about the FLOW3-general mailing list