[TYPO3-mvc] Own Domain Model Validator - whats the right way as of 1.4.1?

Tim Schoch | GSTALTIG tim.schoch at gstaltig.ch
Wed Nov 23 09:41:25 CET 2011


Hello List

I'm a little lost here and need some help about what's the «right» way to validate a domain model.

Current state: 
I have an Domain Model that needs it's custom Validator. My first guess was to take a look at the 
GenericObjectValidator to see how its done, but seeing as it extends a depreciated class I wonder what 
would be the right was as of 1.4.1 to do this.
Am I right when I extend the GenericObjectValidator, overriding the validate() and canValidate() methods?

Also, I wonder what's the best practice for the error handling inside my validator? I would return general 
errors (eg. wrong Class passed) like this. (as in the genericObjectValidator)
$messages = new Tx_Extbase_Error_Result();
$messages->addError(new Tx_Extbase_Validation_Error('Object expected, ' . gettype($object) . ' given.', 1241099149));
return $messages;

But how do I handle Property Errors? I validate them inside the DomainModelValidator and would like to 
be able to use them with the new fluid error viewhelpers.

Any hint is very appreciated.

Tim


More information about the TYPO3-project-typo3v4mvc mailing list