Hi,
There is a bug in validation that affects 'regex', 'match' and 'contains' tests. The parameters for these rules are forced to lower case so matches to fields with upper case values are not possible.
As of Form 3.2 (current) in \Leaf\Form:test we see:
foreach ($rule as $currentRule) {
$param = [];
$currentRule = strtolower($currentRule); // TOO EARLY | NOT NEEDED?
if ($currentRule === 'optional') {
continue;
}
if ($currentRule === 'expanded') {
continue;
}
if (preg_match('/^[a-zA-Z]+<(.*(\|.*)*)>$/', $currentRule)) { // MOVE UP??
$ruleParts = explode('<', $currentRule);
$ruleParams = str_replace('>', '', $ruleParts[1]);
$currentRule = $ruleParts[0];
$param = $ruleParams;
}
if (strpos($currentRule, ':') !== false && strpos($currentRule, '|') === false) { // MOVE UP??
$ruleParts = explode(':', $currentRule);
$currentRule = trim($ruleParts[0]);
$param = $ruleParts[1] ? trim($ruleParts[1]) : null;
}
Commenting out strtolower solves my problem, but I think it is useful since it allows rule names to be more flexible with regards to capitalization.
The strtolower($currentRule) comes too early - it forces $param to lowercase since it is split from $curretnRule afterward. This breaks most useful regular expressions. I suggest moving the checks to split out parameters to immediately after $param is declared. Possibly also the previous if statement.
I'm not sure how this interacts with validation of indexed arrays. It's not clear to me how parameters are handled in this case
Thanks for your attention to this!
Hi,
There is a bug in validation that affects 'regex', 'match' and 'contains' tests. The parameters for these rules are forced to lower case so matches to fields with upper case values are not possible.
As of Form 3.2 (current) in \Leaf\Form:test we see:
Commenting out strtolower solves my problem, but I think it is useful since it allows rule names to be more flexible with regards to capitalization.
The strtolower($currentRule) comes too early - it forces $param to lowercase since it is split from $curretnRule afterward. This breaks most useful regular expressions. I suggest moving the checks to split out parameters to immediately after $param is declared. Possibly also the previous if statement.
I'm not sure how this interacts with validation of indexed arrays. It's not clear to me how parameters are handled in this case
Thanks for your attention to this!