|Don't ask to ask, just ask|
Problems with not so trivial data validation using Data::FormValidatorby ted.byers (Monk)
|on Jan 31, 2013 at 22:43 UTC||Need Help??|
ted.byers has asked for the
wisdom of the Perl Monks concerning the following question:
Maybe I am cognitively challenged, but I thought I did what the documentation says to do if there are multiple constraints to apply to a given field. To be clear, here is what the documentation says (a direct quote, but I don't see anything in the interface for editing this that lets me distinguish between such a quote and what I write)
Multiple constraints can be applied to a single field by defining the value of the constraint to be an array reference. Each of the values in this array can be any of the constraint types defined above.
When using multiple constraints it is important to return the name of the constraint that failed so you can distinguish between them. To do that, either use a named constraint, or use the hash ref method of defining a constraint and include a name key with a value set to the name of your constraint. Here's an example:
You can use an array reference with a single constraint in it if you just want to have the name of your failed constraint returned in the above fashion. Read about the validate() function above to see how multiple constraints are returned differently with that method.
Now here is what I tried:
Of course, this is part of a large profile hash that, prior to my attempt to use multiple constraints, was working fine. Now, here is the error I get:[Thu Jan 31 15:58:27 2013] [error] [client 127.0.0.1] Value for constraint_method 'ccexp' not a code reference or Regexp . Do you need func(), not 'func'? at C:/Perl64/site/lib/Data/FormValidator.pm line 974., referer: http://localhost:9080/test.dfv.html
I am using the following packages.
If there are others that you believe would be useful, I'd appreciate hearing about them, but as far as I can see, the ones I am using are pretty much sufficient for what I need right now.
Any insight on how I can fix these constraints would be appreciated.