Package io.github.dornol.excelkit.excel
Class ExcelValidation
java.lang.Object
io.github.dornol.excelkit.excel.ExcelValidation
Advanced data validation configuration for Excel columns.
Supports integer, decimal, text length, date, and custom formula validations. Use the static factory methods to create validation instances.
writer.column("Age", Person::getAge, c -> c
.validation(ExcelValidation.integerBetween(1, 150)));
- Since:
- 0.7.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSupported validation types. -
Method Summary
Modifier and TypeMethodDescriptionstatic ExcelValidationCreates a validation that restricts dates between start and end (inclusive).static ExcelValidationdecimalBetween(double min, double max) Creates a validation that requires a decimal between min and max (inclusive).errorMessage(String errorMessage) Sets the error dialog message.errorTitle(String errorTitle) Sets the error dialog title.static ExcelValidationCreates a validation using a custom Excel formula.static ExcelValidationintegerBetween(int min, int max) Creates a validation that requires an integer between min and max (inclusive).static ExcelValidationintegerGreaterThan(int min) Creates a validation that requires an integer greater than the given value.static ExcelValidationintegerLessThan(int max) Creates a validation that requires an integer less than the given value.static ExcelValidationlistFromRange(String range) Creates a list validation that references a cell range for dropdown options.showError(boolean showError) Sets whether to show the error dialog when validation fails.static ExcelValidationtextLength(int min, int max) Creates a validation that restricts text length between min and max (inclusive).
-
Method Details
-
integerBetween
Creates a validation that requires an integer between min and max (inclusive).- Parameters:
min- minimum value (inclusive)max- maximum value (inclusive)- Returns:
- the validation instance
-
integerGreaterThan
Creates a validation that requires an integer greater than the given value.- Parameters:
min- the minimum threshold (exclusive)- Returns:
- the validation instance
-
integerLessThan
Creates a validation that requires an integer less than the given value.- Parameters:
max- the maximum threshold (exclusive)- Returns:
- the validation instance
-
decimalBetween
Creates a validation that requires a decimal between min and max (inclusive).- Parameters:
min- minimum value (inclusive)max- maximum value (inclusive)- Returns:
- the validation instance
-
textLength
Creates a validation that restricts text length between min and max (inclusive).- Parameters:
min- minimum text length (inclusive)max- maximum text length (inclusive)- Returns:
- the validation instance
-
dateRange
Creates a validation that restricts dates between start and end (inclusive).- Parameters:
start- the earliest allowed dateend- the latest allowed date- Returns:
- the validation instance
-
listFromRange
Creates a list validation that references a cell range for dropdown options.Use this when dropdown options come from another sheet or cell range instead of inline string arrays.
- Parameters:
range- the cell range reference (e.g., "Sheet2!$A$1:$A$10")- Returns:
- the validation instance
-
formula
Creates a validation using a custom Excel formula.- Parameters:
formula- the Excel formula- Returns:
- the validation instance
-
errorTitle
Sets the error dialog title.- Parameters:
errorTitle- the error dialog title- Returns:
- this instance for chaining
-
errorMessage
Sets the error dialog message.- Parameters:
errorMessage- the error message text- Returns:
- this instance for chaining
-
showError
Sets whether to show the error dialog when validation fails.- Parameters:
showError- whether to show the error dialog- Returns:
- this instance for chaining
-