[TYPO3-mvc] CHANGE: ValidatorInterface is now required for custom validators

Xavier Perseguers typo3 at perseguers.ch
Fri Jul 31 11:54:17 CEST 2009


Hi,

After updating Extbase I discovered that implementing 
Tx_Extbase_Validation_Validator_ValidatorInterface is now required when 
one creates a custom validator (extending 
Tx_Extbase_Validation_Validator_AbstractValidator).

I did not check when this change occured but point is that I discovered 
it this morning while updating my production website :-/ (OK I must 
admin I forgot to check *that* page that used the plugin having a need 
for the custom validator on my dev system before). But anyway, that's an 
important change.

For the others, error was:

Fatal error: Call to undefined method LocaleDateTime::setOptions()

My LocaleDateTime class was defined as this:

class LocaleDateTime extends DateTime {
    ...
}

And my Validator as this:

class LocaleDateTimeValidator extends 
Tx_Extbase_Validation_Validator_AbstractValidator {

}

It seems that classes that provide their validator should yet implements 
Tx_Extbase_Validation_Validator_ValidatorInterface:

class LocaleDateTime
     extends DateTime
     implements Tx_Extbase_Validation_Validator_ValidatorInterface {

    ...
}

And as such have three new methods:

- public function isValid($value)
- public function setOptions(array $validationOptions)
- public function getErrors()

What is possible too is that it was always the case but actually these 
methods were still never called, meaning I did not see that an interface 
was needed.

-- 
Xavier Perseguers
http://xavier.perseguers.ch/en

One contribution a day keeps the fork away


More information about the TYPO3-project-typo3v4mvc mailing list