Method for escaping dot syntax
Opened this issue · 0 comments
golee commented
In case of data array key has dot, the validator broke.
Example
$phpArray = [
'google.com' => 'google',
'youtube.com' => 'youtube'
];
$rules = [
'required' => ['google.com', 'youtube.com']
];
$v = new \Valitron\Validator($phpArray);
$v->rules($rules);
echo $v->validate() ? "passed\n" : "failed\n";
print_r($v->errors());
Result
failed
Array
(
[google.com] => Array
(
[0] => Google.com is required
)
[youtube.com] => Array
(
[0] => Youtube.com is required
)
)
The reason validation failed is that valitron recognize google.com
as array like ...
['google' => ['com' => null]]
So I need a method to distinguish between dot syntax and normal dot. Such as google\.com
{google.com}