Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.3.2

Request #18133 Message parameter for rule
Submitted: 2010-12-22 11:44 UTC
From: char101 Assigned: avb
Status: Closed Package: HTML_QuickForm2 (version 0.5.0)
PHP Version: 5.3.4 OS: All
Roadmaps: 0.6.0    
Subscription  


 [2010-12-22 11:44 UTC] char101 (Charles Gunawan)
Description: ------------ Since a node validation status is based on its error length and the error string is based on a rule message, I think the second parameter in Rule constructor ($message) public function __construct(HTML_QuickForm2_Node $owner, $message = '', $config = null) should not have default value or have a not empty default value. Otherwise if the developer forgot to add the message parameter, the validation will pass even if it failed. Test script: --------------- $form->addText('u')->setLabel('Username')->addFilter('trim')->addRule('required'); Expected result: ---------------- I expect the form to be invalid if 'u' is empty or that I get a warning mesage stating that the rule message is missing. Actual result: -------------- The form validates.

Comments

 [2011-03-10 02:06 UTC] avb (Alexey Borzov)
-Status: Open +Status: Analyzed
I am not sure whether it is a good idea to change a default value of $message, but required rules without a message should definitely raise an exception. We already disallow chaining required rules for the very same reason. I'm also going to document the need to provide error messages for rules in the end-user docs.
 [2011-03-15 13:55 UTC] avb (Alexey Borzov)
Documented validation behaviour and necessity of error messages: http://pear.php.net/manual/en/package.html.html-quickform2.rules.php
 [2011-03-28 16:10 UTC] avb (Alexey Borzov)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: avb
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.