Bug #35136

Problem with validating simple types

Added by Rens Admiraal over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
-
Target version:
-
Start date:
2012-03-22
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

When an argument of a controller action is annotated with @param integer $var, the validation never fails if a string is passed to the argument.

This is because the TypeConverter returns (integer) $value, which will always match on the Validator. This could for example be solved with something like this in the TypeCoverter:

        if (!is_numeric($source)) {
            throw new \TYPO3\FLOW3\Exception('Can\'t convert source value to integer', 1332411849);
        }

Problem with this approach is the output: an unfriendly error.

Maybe it would be possible to do a quick validation on simple types before the actual TypeConverter starts doing his job?

Also available in: Atom PDF