use of org.summerb.approaches.validation.errors.DataTooLongValidationError in project summerb by skarpushin.
the class DaoExceptionUtils method propagateIfTruncationError.
/**
* @deprecated This feature will not actually work at least with mysql.
* MySql doesn't send the numbers - it sends only field name
* which was truncated.
*/
@Deprecated
public static void propagateIfTruncationError(Throwable t) throws FieldValidationException {
DataTruncation exc = ExceptionUtils.findExceptionOfType(t, DataTruncation.class);
if (exc == null) {
return;
}
String fieldName = findTruncatedFieldNameIfAny(t);
if (fieldName == null) {
return;
}
DataTooLongValidationError dataTooLongValidationError = new DataTooLongValidationError(exc.getDataSize(), exc.getTransferSize(), fieldName);
throw new FieldValidationException(dataTooLongValidationError);
}
use of org.summerb.approaches.validation.errors.DataTooLongValidationError in project summerb by skarpushin.
the class ValidationContext method validateDataLengthLessOrEqual.
public boolean validateDataLengthLessOrEqual(String str, int maxLength, String fieldToken) {
int len = str == null ? 0 : str.length();
if (len <= maxLength) {
return true;
}
add(new DataTooLongValidationError(len, maxLength, fieldToken));
return false;
}
Aggregations