Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:7.xfrom
tobiasnitsche:patch-1
May 12, 2020
Merged

[7.x] Fix Validator, getPrimaryAttribute returns wrong attribute#32775
taylorotwell merged 1 commit into
laravel:7.xfrom
tobiasnitsche:patch-1

Conversation

@tobiasnitsche
Copy link
Copy Markdown
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