Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method for escaping dot syntax #305

Open
golee opened this issue Feb 14, 2020 · 0 comments
Open

Method for escaping dot syntax #305

golee opened this issue Feb 14, 2020 · 0 comments

Comments

@golee
Copy link

golee commented Feb 14, 2020

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}

@golee golee changed the title Method for escape dot syntax Method for escaping dot syntax Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant