Class InventoryCsvValidator
java.lang.Object
com.amilesend.discogs.csv.InventoryCsvValidator
Utility to read an inventory CSV file and validate its contents based on the specification as described
in the API Documentation.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newInventoryCsvValidator
instance with the default CSVFormat configured.InventoryCsvValidator
(@NonNull org.apache.commons.csv.CSVFormat csvFormat) -
Method Summary
Modifier and TypeMethodDescriptionvoid
validate
(@NonNull Path csvFile, @NonNull InventoryRecordType type) Validates an inventory CSV file by: Validating that headers are recognized Required headers are present Contents adhere to column value constraints
-
Constructor Details
-
InventoryCsvValidator
public InventoryCsvValidator()Creates a newInventoryCsvValidator
instance with the default CSVFormat configured.- See Also:
-
InventoryCsvValidator
public InventoryCsvValidator(@NonNull org.apache.commons.csv.CSVFormat csvFormat)
-
-
Method Details
-
validate
public void validate(@NonNull Path csvFile, @NonNull InventoryRecordType type) throws IOException, ValidationException Validates an inventory CSV file by:- Validating that headers are recognized
- Required headers are present
- Contents adhere to column value constraints
- Parameters:
csvFile
- the CSV file to validatetype
- the type of operation that the CSV file is for (i.e., new inventory, or updating existing inventory items).- Throws:
IOException
- if an error occurred while attempting to read the fileValidationException
- if the file failed validation. SeeValidationException.getErrors()
for a detailed description of each validation error- See Also:
-