[TYPO3-mvc] How to register a custom validator

Peter Niederlag typo3-list at niekom.de
Tue Apr 12 16:55:42 CEST 2011


Hello,

Am 12.04.2011 14:51, schrieb François Suter:
> Hi,
>
>> Doublde Cross Check the spelling. It might also be required to end in
>> 'Validator'.
>>
>> @validate Tx_Foo_Validation_Validator_DateValidator(minAge=18)
>>
>> works for me.
>
> Thanks, but no luck... To compare the setup, in which path is your
> validation class file stored, how is it named?

To be able to use autoloading it HAS to be named:

'FILE:EXT:Foo/Classes/Validation/Validator/DateValidator.php'

class Tx_Foo_Validation_Validator_DateValidator extends 
Tx_Extbase_Validation_Validator_AbstractValidator {}

That's the beauty of "convention over configuration", just the classname 
will tell you the name and path of the file. :->

It is working on extbase 1.2, don't have an example with recent extbase 
yet, so it could be a bug sneaked in.

Greets and hth,
Peter

P.S.: for testing, just add a die('include me'); somewhere in the first 
lines of file to see wether it is included at all....
P.S.II: Validators are only triggered by MVC properyt mapping (not when 
using the plain objects, for example within a task)
-- 
Peter Niederlag
http://www.niekom.de * TYPO3 & EDV Dienstleistungen *


More information about the TYPO3-project-typo3v4mvc mailing list