[TYPO3-ect] validator heresy
Elmar Hinz
elmar07 at googlemail.com
Thu Aug 16 01:37:50 CEST 2007
Hi Steve,
Steve Ryan wrote:
> I'm having a go at generation of validator rules from TCA.
> I'm looking at using something like
> 10 {
> field = title
> pattern = /.+/
> message = %%%emptyTitleError%%%
> }
> 20 {
> field = text
> php = if (substr($value)) $return=true;
> message = %%%incorrectTextError%%%
> }
>
> to achieve some of the rules that can't be accomplished by preg like
> unique.
>
> Doesn't smell good but it's convenient ????? Don't imagine that hacking
> php snippets into otherwise such well structured codes is not going to
> be popular. The value is being able to structure a much more flexible
> rule set into an object.
We also mix PHP into templates. :-) So the slashers have already something
to cut.
>
> Extension class to validator below
> Use it as follows
> $rules=$this->getValidationRulesFromTCA('fe_users','name,email,address');
Good point.
That flushes the idea of an easy TCA access API into my mind. Something
analogous to configurations and parameters. (useful for model, forms,
validation)
>
> function validate($object = null) {
> if(is_object($object)) {
> $this->setArray($object);
> }
> if(is_array($this->rules)) {
> $this->_validateByPREGAndPHPRules();
The original function name "_validateByRules()" already shows that I had
further types of validation in mind.
I wouldn't do things this monolithic:
$this->_validateByPREGAndPHPRules();
Small functions == many options.
See this wild batch ...
$this->_validateByTca();
$this->_validateByTs();
$this->_validateByPhp();
$this->_validateByXml();
$this->_validateByVoodoo();
...
More information about the TYPO3-team-extension-coordination
mailing list