[TYPO3-50-general] optional or nested validators

Pascal Jungblut mail at pascal-jungblut.com
Thu Oct 8 18:58:03 CEST 2009


I'm curious about the validation feature. Let's assume I have an  
optional field in fe_users (e.g. 'zip'). I want the user to enter  
either nothing _or_ a five-digit number. As I see it, there is  
currently no possibility to use the DisjunctionValidator that would  
allow something like:

@validate Empty, StringLength(minimum = 5, maximum = 5)

So if I think one step further I would want to combine the  
DisjunctionValidator and ConjunctionValidator or even nest them:

@validate OR(Empty, AND(String, StringLength(minimum = 3, maximum = 5)))

Of course, I could write a new validator for that but it would reduce  
code-redundancy if one were able to nest the validators.

Is this already possible? If not: how would you validate something  
that is optional?
I'd like to implement the nested-feature but I don't know if you like  
the idea.


More information about the TYPO3-project-5_0-general mailing list