[TYPO3-mvc] Validation

Sebastian KurfŸürst sebastian at typo3.org
Tue Jun 9 17:52:09 CEST 2009


Hey Sebastian,

> I know that i need to put reference to a validator into the phpdoc but 
> how does it work? Does it use reflection?
Yep, it uses reflection.

There are several places where you can insert validations:

-- Inside the Domain Model:
In the PHPDoc above properties, you can write @validate annotations.

A "@validate" annotation has always the following format:

@validate Validator1, ..., ValidatorN


-- Inside the Controller

The @validate annotation has the following format here:
@validate $VariableName Validator1, ..., ValidatorN

So that is basically the same as inside the domain model, just the 
$VariableName is added.


-- General

Where each Validator is a short validator name (which is resolved inside 
Tx_Extbase_Validation_Validator_...) - as an example "@validate 
Alphanumeric".
The validator can also be a fully qualified class name to a custom 
validator (which needs to implement the 
Tx_Extbase_Validation_Validator_ValidatorInterface).


If the validator needs some arguments, you can specify them in brackets.
Example:
@validate StringLength(minimum=3, maximum=50)




I hope this helps a bit :-)

Greets,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list