Complex validation not working #2987
-
I'm creating a program to import certain data into a Laravel application. I have two columns, city and state, and those should be validated by the app. I need to validate that a city has the right state associated with it. It seems I cannot do it using validation rules because in order to validate that a city belongs to the correct state I need access to both the city and the state fields. But I only have access to the current data being validated, not the whole row. It looks like it can be done using a complex validation using the withValidator() method (https://docs.laravel-excel.com/3.1/imports/validation.html#configuring-the-validator). Example of my code (simplified):
But once I perform the validation, I get a I'm not sure if I'm missing something or if this is not the way it's supposed to be used but I've tried everything and there's little documentation in the net about it. Tagging @axlon since he's the author of this PR. Any help is relly appreciated! Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @jmunozpcoco, Judging from the error you are getting I think you need to prefix your column name with a row number e.g. |
Beta Was this translation helpful? Give feedback.
-
You are trying to add an error to a column that does not exist. I'm okay with a PR that allows that |
Beta Was this translation helpful? Give feedback.
You are trying to add an error to a column that does not exist. I'm okay with a PR that allows that
$rows[$row] ?? null