DataValidation dv = sheet.getDataValidation(row, col);
//no validation constraint
if (dv == null) {
return null;
}
final DataValidationConstraint constraint = dv.getValidationConstraint();
//allow any value => no need to do validation
if (constraint.getValidationType() == ValidationType.ANY) { //can be any value, meaning no validation
return null;
}
//ignore empty and value is empty
if (value == null || (value instanceof String && ((String)value).length() == 0)) {
if (dv.getEmptyCellAllowed()) {
return null;
}
}
//get new evaluated formula value
if (cellType == Cell.CELL_TYPE_FORMULA) {
final Book book = sheet.getBook();
final int sheetIndex = book.getSheetIndex(sheet);
final CellValue cv = BookHelper.evaluateFormula(book, sheetIndex, (String) value);
value = BookHelper.getValueByCellValue(cv);
cellType = cv.getCellType();
}
//start validation
boolean success = true;
switch(constraint.getValidationType()) {
// Integer ('Whole number') type
case ValidationType.INTEGER:
if (!isInteger(value) || !validateOperation(sheet, constraint, (Number)value)) {
success = false;
}