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

[Bug]: the column displayed in the error message is not the correct one for validation rules require_with:*.<number> #4077

Closed
1 task done
CelienFiorelli opened this issue Jan 31, 2024 · 2 comments
Labels

Comments

@CelienFiorelli
Copy link

Is the bug applicable and reproducable to the latest version of the package and hasn't it been reported before?

  • Yes, it's still reproducable

What version of Laravel Excel are you using?

3.1.48

What version of Laravel are you using?

6

What version of PHP are you using?

7

Describe your issue

when using rules require_with:. in import without header, if the rules ends with 0 (e.g. require_with:.30), the custom name defined in "customValidationAttributes" displayed in the error message is that of column 3 instead of column 30 (the validation verifies the presence of the correct column, only the error message displays an error)

How can the issue be reproduced?

Create 11 columns with custom validation rules and custom validation attributes, with the 10th having a "required_with:.11" and the 11th a required_with:.10", then import an excel without the 11 column. the error display will say that the "custom attribute11" is required with the "custom attribute1" instead of "custom attribute10".

public function rules(): array
{
    return [
        '1' => ['random rules'],
        ...
        '10' => ['nullable', 'required_with:*.11'],
        '11' => ['nullable', 'required_with:*.10']
    ];
}
public function customValidationAttributes()
{
    return [
        '1' => 'custom attribute1',
        ...
        '10' => 'custom attribute10',
        '11' => 'custom attribute11',
    ];
}

What should be the expected behaviour?

when validating the 11th column, if column 10 is not present in row, the custom validation attribute displayed in the error should be 10 and not 1

@patrickbrouwers
Copy link
Member

It seems you are not on the latest version of this package. Can you try updating, as something with validation rules were fixed in the latest release.

If it's not fixed, can you please PR een failing unit test for this.

@patrickbrouwers
Copy link
Member

I've tried to recreate it via a unit test, but cannot reproduce: c35a38e

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

No branches or pull requests

2 participants