1 package com.opencsv.validators; 2 3 import com.opencsv.exceptions.CsvValidationException; 4 5 /** 6 * This is the interface for validators for an array of {@link String}s read by 7 * the {@link com.opencsv.CSVReader} after it is processed. 8 * This should only be used if you have a very good understanding and full 9 * control of the data being processed. Good examples of a RowValidator would 10 * be to ensure the number of columns in the row or, if you know what data are 11 * in which column, check the format and type of data. 12 * 13 * @author Scott Conway 14 * @since 5.0 15 */ 16 public interface RowValidator { 17 /** 18 * Performs the validation check on the string and returns the result. 19 * While not called directly in opencsv it is in the interface to provide 20 * an easy way to test if the validator is functioning properly. 21 * 22 * @param row Array of strings to be validated 23 * @return {@code true} if the row is valid, {@code false} otherwise 24 */ 25 boolean isValid(String[] row); 26 27 /** 28 * Performs the validation check on the row (an array of {@link String}s) 29 * and throws an exception if invalid. 30 * 31 * @param row Array of {@link String}s to be validated. 32 * @throws CsvValidationException Thrown if invalid. Should contain a 33 * message describing the error. 34 */ 35 void validate(String[] row) throws CsvValidationException; 36 }