added max length validation for datatables
This commit is contained in:
+1
-1
@@ -117,7 +117,7 @@ public final class ResultsetColumnHeaderData {
|
||||
return "datetime".equalsIgnoreCase(this.columnType);
|
||||
}
|
||||
|
||||
private boolean isString() {
|
||||
public boolean isString() {
|
||||
return isVarchar() || isChar();
|
||||
}
|
||||
|
||||
|
||||
+12
-6
@@ -1165,24 +1165,30 @@ public class ReadWriteNonCoreDataServiceImpl implements ReadWriteNonCoreDataServ
|
||||
} else {
|
||||
paramValue = tmpDate.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (columnHeader.isIntegerDisplayType()) {
|
||||
} else if (columnHeader.isIntegerDisplayType()) {
|
||||
Integer tmpInt = helper.convertToInteger(paramValue, columnHeader.getColumnName(), clientApplicationLocale);
|
||||
if (tmpInt == null) {
|
||||
paramValue = null;
|
||||
} else {
|
||||
paramValue = tmpInt.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (columnHeader.isDecimalDisplayType()) {
|
||||
} else if (columnHeader.isDecimalDisplayType()) {
|
||||
BigDecimal tmpDecimal = helper.convertFrom(paramValue, columnHeader.getColumnName(), clientApplicationLocale);
|
||||
if (tmpDecimal == null) {
|
||||
paramValue = null;
|
||||
} else {
|
||||
paramValue = tmpDecimal.toString();
|
||||
}
|
||||
} else if (columnHeader.isString()) {
|
||||
if (paramValue.length() > columnHeader.getColumnLength()) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.datatable.entry.column.exceeds.maxlength",
|
||||
"The column `" + columnHeader.getColumnName() + "` exceeds its defined max-length ",
|
||||
columnHeader.getColumnName(), paramValue);
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
dataValidationErrors.add(error);
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
|
||||
dataValidationErrors);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user