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

[5.3] Fix validating distinct for nested keys #17102

Merged
merged 1 commit into from
Jan 3, 2017
Merged

[5.3] Fix validating distinct for nested keys #17102

merged 1 commit into from
Jan 3, 2017

Conversation

themsaid
Copy link
Member

@themsaid themsaid commented Jan 3, 2017

We currently use Str::is($attributeName, $key) to see if the given key matches the pattern we use to check for distinct values which is foo.*.bar, the problem is that foo.*.bar matches foo.1.nested.bar which shouldn't be matched, so in this PR I use regex instead of the is() helper.

I replace * in the pattern with [^.]+ to match any character by the dot.

@themsaid themsaid deleted the distinctMatching branch January 3, 2017 16:16
@jhayiwg
Copy link

jhayiwg commented Mar 16, 2017

Hello,

Im still new with laravel and Im having problem using the validation I have a repeater fields that should validate 3 unique fields
example:
should be true if [ [ a => 1, b=>2, c=>3 ], [ a => 1, b=>2, c=>4 ]]
it should be failed if [ [ a => 1, b=>2, c=>3 ], [ a => 1, b=>2, c=>3 ]]

Base from what I see from the test it is only checking 1 field is there any way to validate somethink like this

Validator($trans, [ [ a => 1, b=>2, c=>3 ], [ a => 1, b=>2, c=>3 ]], ['foo.*.[a,b,c]' => 'distinct']);

I`m also using laravel 3

Many thanks

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

Successfully merging this pull request may close these issues.

None yet

3 participants