❔ Validate list of objects after reading excel file
Hi all, how would you validate data from excel file with fluent validation?
I have method which will read data from excel file and return me list of person objects. After read I call validator to validate data from excel file. Person email must be unique, so it shouldn't exist in database when I read data and it shouldn't be duplicated in excel file.
Is it good approach to inject repository in validator or just collect all emails as list and pass it to validator? If I use that approach what if someone else insert person with email in parallel with my operation?
Person class:
Person validator class:
I have method which will read data from excel file and return me list of person objects. After read I call validator to validate data from excel file. Person email must be unique, so it shouldn't exist in database when I read data and it shouldn't be duplicated in excel file.
Is it good approach to inject repository in validator or just collect all emails as list and pass it to validator? If I use that approach what if someone else insert person with email in parallel with my operation?
Person class:
Person validator class:
