-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Hey hey,
I noticed some problem while using regex that contains comma.
when you have rule like this: regex:/^([a-zA-Z\,]*)$/
Final regex will be /^([a-zA-Z\
And that will result in following warning: Warning: preg_match(): No ending delimiter '/' found in ../rakit/validation/src/Rules/Regex.php on line 18
That is main problem with parseRule method, that splits params no mater what.
instead:
protected function parseRule($rule)
{
$exp = explode(':', $rule, 2);
$rulename = $exp[0];
$params = isset($exp[1])? explode(',', $exp[1]) : [];
return [$rulename, $params];
}
should be something like this:
protected function parseRule($rule)
{
$exp = explode(':', $rule, 2);
$rulename = $exp[0];
if ($rulename !== 'regex') {
$params = isset($exp[1])? explode(',', $exp[1]) : [];
} else {
$params = [$exp[1]];
}
return [$rulename, $params];
}