Hello,
I found a minor issue with the numeric validation rule (using Cook 2.0). I have a required number field (int) in a table, for which 0 is an valid value. The JQuery validation works fine, but when the form rule is invoked from the server it generates an error when '0' is entered.
By looking at the code for the validation I spotted the issue. It is in in the /classes/rule.php class. When it does the required and empty check in the beginning of the testDefaults method it uses PHP's empty method to test if a value has been provided. However, this function considers values like 0, or 0.0, or '0' to be empty!
I fixed it as follows around line 96 in the testDefaults method:
if ($required && empty($value))
{
// valid when not numeric, or when it is a valid value
return (($element['validate']!="numeric")||(is_numeric($value)));
// return false;
}
Kind regards,
Misha