-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Validating array where keys contain forward slashes #25146
Comments
You must be running an older Laravel version. It works for me and |
Yes and no. This is the 5.3 patch: 0b04c1d The exception is thrown in line 61:
because preg_quote is missing the '/' parameter in line 57. This works fine:
|
Cannot reproduce on 5.6.29:
|
Are you using wildcard rules with |
Sorry guys, I did not give you enough information. So here is the failing code (tinker):
The problem only exists, when you include the sometimes validator. If sometimes is not in the list of validators, the code works fine. In my production code I use sometimes|array|nullable. Thanks! |
Description:
When running validator on an array key which contains a forward slash, I run into an error exception in Validator.php line 2716 (Validator::getExplicitKeys($attribute), where preg_match is run on $pattern generated from the attribute.
I have not found the proper way (if there is any) to escape this forward slash, and note that in my use case the data comes in a pre-specified format which I cannot change. I realise I could change the key before validation, but I am wondering if there is a way to make the validator work as-is, or if the validator is even intended to work in this case.
The bug was already discuessed and fixed in 5.3: #16287
but was re-introduced in 5.4.
Steps To Reproduce:
The following code does not work, since calling $validator->fails() generates the ErrorException.
The text was updated successfully, but these errors were encountered: