[TYPO3-mvc] How to register a custom validator

François Suter fsu-lists at cobweb.ch
Tue Apr 12 11:49:28 CEST 2011


Hi all,

AFAIK it's possible to create custom validators, but I couldn't find any 
information about how to write and register them properly.

In my extension I have created the following structure:

Classes > Domain > Validator > BirthYear.php

Inside the PHP file, the class is called:

Tx_Myext_Domain_Validator_BirthYearValidator

It extends Tx_Extbase_Validation_Validator_AbstractValidator and 
implements the isValid() method.

To try and use it, I have defined a property such as:

/**
  * Year of birth of the patient involved
  *
  * @var integer $patientBirthYear
  * @validate BirthYear
  */
protected $patientBirthYear;

but that leads to an exception about the validator for "BirthYear" not 
being found. I also tried to use the "full" name of the validator:

  * @validate Tx_Latourrisk_Domain_Validator_BirthYear

without more success. While not entirely surprised, the question is then 
what is wrong in the above setup?

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch


More information about the TYPO3-project-typo3v4mvc mailing list