[Flow] Using aspects to change EmailAddressValidator

Bastian Waidelich bastian at typo3.org
Mon Jan 6 16:59:49 CET 2014


Steffen Wickham wrote:

Hi Steffen,

> I achieved a solution for my problem by changing the "isValid()" method
> of ElectronicAddressValidator class of TYPO3.Party package via AOP. It
> is no clean way, anyway it works at the moment.

Good news!
As a rule of thumb you should try to avoid AOP if you don't need it 
because it adds a level of complexity and obscurity to your code base. 
But in this case I don't see a better way currently.

What I had in mind was an entry in Objects.yaml like:

  TYPO3\Flow\Validation\Validator\EmailAddressValidator:
   className: 'Your\Package\Validation\Validator\EmailAddressValidator'

But I just realized that overriding the implementation class name only 
works for interfaces so that won't work.



> But I will have a look on the behaviour of AOP in conjunction with the
> validatorResolver in a few days. There seems to be a bug which prevents
> the framework to apply aspects to the called methods. Will keep you
> updated.

I'm not aware of bugs in that area. So, yes, please keep us posted.


> Thanks guys! :)

You're welcome ;)


BTW: I tend to avoid the person model of the package for my applications 
as its making many scenarios more complicated than they need to be. If 
you don't need all the flexibility of multiple "electronic addresses" 
and names I'd suggest to create a minimal person model that extends 
AbstractParty (see [1] for an example). It makes your code easier to 
read/maintain and you have all the power over validation rules etc.



[1] https://gist.github.com/bwaidelich/6292221

-- 
Bastian Waidelich


More information about the Flow mailing list