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

[7.x] Fix Validator, getPrimaryAttribute returns wrong attribute #32775

Merged
merged 1 commit into from
May 12, 2020
Merged

[7.x] Fix Validator, getPrimaryAttribute returns wrong attribute #32775

merged 1 commit into from
May 12, 2020

Conversation

tobiasnitsche
Copy link
Contributor

@tobiasnitsche tobiasnitsche commented May 12, 2020

When I want the primary attribute for "1.10", I receive "*.1" and not the expected "*.10". It can be solved with the parameter strict=true of the function in_array.

Here is the testcase :

Parameter $attribute: 1.10

Return: *.1
Expected return: *.10

$this->implicitAttribute:

Array
(
[*.0] => Array
(
[0] => 1.0
[1] => 2.0
)

[*.1] => Array
    (
        [0] => 1.1
        [1] => 2.1
    )

[*.2] => Array
    (
        [0] => 1.2
        [1] => 2.2
    )

[*.3] => Array
    (
        [0] => 1.3
        [1] => 2.3
    )

[*.4] => Array
    (
        [0] => 1.4
        [1] => 2.4
    )

[*.5] => Array
    (
        [0] => 1.5
        [1] => 2.5
    )

[*.6] => Array
    (
        [0] => 1.6
        [1] => 2.6
    )

[*.7] => Array
    (
        [0] => 1.7
        [1] => 2.7
    )

[*.8] => Array
    (
        [0] => 1.8
        [1] => 2.8
    )

[*.9] => Array
    (
        [0] => 1.9
        [1] => 2.9
    )

[*.10] => Array
    (
        [0] => 1.10
        [1] => 2.10
    )

[*.11] => Array
    (
        [0] => 1.11
        [1] => 2.11
    )

)

When I want the primary attribute for "1.10", I receive "*.1" and not the expected "*.10". It  can be solved with the parameter strict=true of the function in_array.

Here is the testcase 


Implicit attributes: 
Array
(
    [*.0] => Array
        (
            [0] => 1.0
            [1] => 2.0
        )

    [*.1] => Array
        (
            [0] => 1.1
            [1] => 2.1
        )

    [*.2] => Array
        (
            [0] => 1.2
            [1] => 2.2
        )

    [*.3] => Array
        (
            [0] => 1.3
            [1] => 2.3
        )

    [*.4] => Array
        (
            [0] => 1.4
            [1] => 2.4
        )

    [*.5] => Array
        (
            [0] => 1.5
            [1] => 2.5
        )

    [*.6] => Array
        (
            [0] => 1.6
            [1] => 2.6
        )

    [*.7] => Array
        (
            [0] => 1.7
            [1] => 2.7
        )

    [*.8] => Array
        (
            [0] => 1.8
            [1] => 2.8
        )

    [*.9] => Array
        (
            [0] => 1.9
            [1] => 2.9
        )

    [*.10] => Array
        (
            [0] => 1.10
            [1] => 2.10
        )

    [*.11] => Array
        (
            [0] => 1.11
            [1] => 2.11
        )

)

Attribute: 1.10
Unparsed: *.1
@tobiasnitsche tobiasnitsche changed the title [7.x] Fix Validator, getPrimaryAttribute returns wrong Attribute [7.x] Fix Validator, getPrimaryAttribute returns wrong attribute May 12, 2020
@taylorotwell taylorotwell merged commit ce2fdc4 into laravel:7.x May 12, 2020
@tobiasnitsche tobiasnitsche deleted the patch-1 branch May 12, 2020 13:31
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