Form validation callables combined with "required" |
(02-09-2016, 12:44 PM)Narf Wrote:(02-09-2016, 10:08 AM)skunkbad Wrote:(02-09-2016, 02:26 AM)Narf Wrote: Well, it's rare that someone doesn't use 'required' AND uses a callback at the same time, but this has been reported as a bug quite a few times. If you change it, what do you propose is a solution to the scenario that mwhitney presents? Maybe a new "not_required" rule?
I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric. But I guess that's precisely why callbacks are executed when there is no "required" rule. Callbacks are for those cases that don't conform to "regular" form validation.
I think the solution that would require the least change and provide the most benefit would be skunkbad's suggestion to make a note of the issue in the documentation. It truly is not a bug but a feature!
Hey, don't work without a PHP debugger. Several free IDEs have this features built in. Two are NetBeans and CodeLobster. Without a debugger, it's like you're driving with a blindfold on -- you are going to crash!
(02-09-2016, 03:59 PM)RobertSF Wrote: I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric. Validation succeeds only if the field is empty, it doesn't blindly trust fields without the "required" rule.
(02-09-2016, 10:16 PM)Narf Wrote:(02-09-2016, 03:59 PM)RobertSF Wrote: I had not expected the absence of "required" to end validation and call it successful. After all, in addition to mwhitney's scenario, there might be a field that is not required, but if supplied, must be numeric. A "required_if" rule might be useful for mwhitney's scenario. I could use one right now as I'm having trouble associating a rule name with a callable rule. If a rule name is supplied (per the third example in "Use anything as a rule") and the field is blank the validation does not run. If I don't supply the rule name it runs but the error message is not found and it returns "Unable to access an error message corresponding to blah, blah, blah..." |
Welcome Guest, Not a member yet? Register Sign In |