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

Allow wildcard field parameters #34

Closed
amitailanciano opened this issue Jul 22, 2016 · 3 comments
Closed

Allow wildcard field parameters #34

amitailanciano opened this issue Jul 22, 2016 · 3 comments

Comments

@amitailanciano
Copy link

Thanks again for putting this out there.

Laravel 5.2 now supports validation arrays, it looks like the phone validator doesn't take advantage of that yet, I'd like to be able to do this:

'something.*.phone' => 'phone:something.*.phone_country'

Similar to what is shown in the docs:

$validator = Validator::make($request->all(), [
    'person.*.email' => 'email|unique:users',
    'person.*.first_name' => 'required_with:person.*.last_name',
]);

https://laravel.com/docs/5.2/validation#validating-arrays

@Propaganistas
Copy link
Owner

Propaganistas commented Jul 23, 2016

I'd love to, but at the moment Laravel doesn't allow third-party packages to implement wildcards in validator parameters...

Parsing of wildcard parameters happens here:
https://github.com/laravel/framework/blob/5.2/src/Illuminate/Validation/Validator.php#L473
In order for this line to fire, the dependsOnOtherFields() conditional should return true. This method however checks the $dependentFields property which, unfortunately, cannot be modified from the outside and as such I cannot mark the phone validator correspondingly...

@Propaganistas
Copy link
Owner

Propaganistas commented Apr 14, 2017

This has been implemented as of Laravel 5.4.18. Will rework the package to make use of this in the near future.

laravel/framework#18654

@Propaganistas
Copy link
Owner

Implemented. Please update to the latest version (and make sure to use Laravel >= 5.4.18):

https://github.com/Propaganistas/Laravel-Phone/releases/tag/2.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants