Bug #57164
closed
NumberRangeValidator does not get options correctly
Added by Thomas Hucke over 10 years ago.
Updated about 7 years ago.
Description
The validation always fails when I add the following annotation in my model
* @validate NumberRange(minimum=1,maximum=999)
Adding DEBUG info to the NumberRangeValidator I see that $this->options[] does not get filled correctly. Only $this->options['minimum'] gets filled. $this->options['maximum'] is not set.
Unfortunately I don´t find the right place to check why the second option doesn´t get filled.
I see that something is weired there but I cannot go more into it - sorry :-(
BTW:
I´d been great if only one option could be mandatory because actually I´d like to check "Greater than" with only providing the 'minimum' option.
Files
Tested with TYPO3 6.2.0rc1 now all given options are read successfully.
But still the default values in $supportedOptions are not recognized.
With the attached patch the code in AbstractCompositeValidator gets reused to keep track of supported/unsupported options.
You may use it as it is.
Sorry - removed debug output from patch
Next fix:
Removed setting $this->options in deprecated method setOptions() according to AbstractCompositeValidator.
Values set in constructor got removed when method is being called e.g. by ValidatorResolver
Final shot of this patch ;-)
Moved the whole code of the construtor to setOptions() and calling that from the constructor.
Added a TODO hint to move code back to the constructor when deprecated method setOptions() gets removed.
That should provide backward compatibility for all cases.
- Status changed from New to Under Review
Hallo Marc,
I´ve tested successfully the modification in my environment.
The reported issue has been resolved.
Thank you very much
Thomas
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Hallo Stefan,
would you please check my comment on the patch.
I´m afraid we have to make another correction.
Sorry for my late test - I'm at work during day and only have limited time to go for those tasks.
Thomas
Issue has been resolved.
My test was false - tested 6.1 patch on 6.2 :-(
- Status changed from Resolved to Closed
Also available in: Atom
PDF