Merge pull request #405 from vishwasbabu/develop

added max length validation for datatables
This commit is contained in:
Vishwas Babu A J
2013-06-27 03:53:06 -07:00
2 changed files with 13 additions and 7 deletions
@@ -117,7 +117,7 @@ public final class ResultsetColumnHeaderData {
return "datetime".equalsIgnoreCase(this.columnType);
}
private boolean isString() {
public boolean isString() {
return isVarchar() || isChar();
}
@@ -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);
}
}
}