Skip to content

Conversation

@bencomeau
Copy link
Contributor

Issue

When using the distinct:ignore_case flag during validation it will fail when evaluating integers; specifically, if the value being checked contains the integer under validation.

Example

Using 'foo.*' => 'distinct:ignore_case' with data such as 'foo' => ['1', '11'] will fail since 11 contains 1.

Similarily, using 'foo.*' => 'distinct:ignore_case' with data such as 'foo' => ['2', '425'] will fail since 425 contains 2.

Cause

The preg_grep() pattern does not contain the start (^) and end ($) characters which leads to the function returning partial matches.

Solution

Add the start (^) and end ($) characters to the preg_grep() pattern. Write additional tests including passing integers to the distinct:ignore_case validation flag.

@themsaid themsaid changed the title Force preg_grep to match entire value using start and end characters [5.5] Force preg_grep to match entire value using start and end characters Nov 29, 2017
@taylorotwell taylorotwell merged commit dc4925f into laravel:5.5 Nov 29, 2017
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.

2 participants