Applied validation for few fields in call
This commit is contained in:
@@ -126,7 +126,7 @@ public class CallDao {
|
||||
callEntity.setConfidi(createCallRequest.getConfidi());
|
||||
}
|
||||
callEntity.setDocumentationRequested(createCallRequest.getDocumentationRequested());
|
||||
if (createCallRequest.getAmountMin().compareTo(BigDecimal.ZERO) < 0) {
|
||||
if (createCallRequest.getAmountMin() != null && createCallRequest.getAmountMin().compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||
}
|
||||
callEntity.setAmountMin(createCallRequest.getAmountMin());
|
||||
@@ -474,6 +474,18 @@ public class CallDao {
|
||||
setIfUpdated(callEntity::getAmountMax, callEntity::setAmountMax, updateCallRequest.getAmountMax());
|
||||
setIfUpdated(callEntity::getDocumentationRequested, callEntity::setDocumentationRequested,
|
||||
updateCallRequest.getDocumentationRequested());
|
||||
|
||||
if (updateCallRequest.getAmountMin() != null && updateCallRequest.getAmountMin().compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||
}
|
||||
if(updateCallRequest.getEmail()==null || Boolean.FALSE.equals(Utils.isValidEmail(updateCallRequest.getEmail()))){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.VALIDATION_EMAIL,updateCallRequest.getEmail()));
|
||||
}
|
||||
setIfUpdated(callEntity::getAmountMin, callEntity::setAmountMin, updateCallRequest.getAmountMin());
|
||||
setIfUpdated(callEntity::getEmail, callEntity::setEmail, updateCallRequest.getEmail());
|
||||
setIfUpdated(callEntity::getPhoneNumber, callEntity::setPhoneNumber, updateCallRequest.getPhoneNumber());
|
||||
setIfUpdated(callEntity::getStartTime, callEntity::setStartTime, DateTimeUtil.parseTime(updateCallRequest.getStartTime()));
|
||||
setIfUpdated(callEntity::getEndTime, callEntity::setEndTime, DateTimeUtil.parseTime(updateCallRequest.getEndTime()));
|
||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||
updateLookUpData(callEntity, updateCallRequest.getAimedTo(), LookUpDataTypeEnum.AIMED_TO);
|
||||
updateFaq(updateCallRequest.getFaq(), callEntity, userEntity, LookUpDataTypeEnum.FAQ);
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
@@ -25,6 +26,16 @@ public class UpdateCallRequestStep1 {
|
||||
|
||||
private String documentationRequested;
|
||||
|
||||
private BigDecimal amountMin;
|
||||
|
||||
private String email;
|
||||
|
||||
private String phoneNumber;
|
||||
|
||||
private String startTime;
|
||||
|
||||
private String endTime;
|
||||
|
||||
private Boolean confidi;
|
||||
|
||||
private List<FaqReq> faq;
|
||||
|
||||
@@ -30,9 +30,9 @@ public class CallValidatorServiceImpl {
|
||||
.notNull(response.getAmountMax(), "amountMax")
|
||||
.notNull(response.getThreshold(), "threshold")
|
||||
.notNull(response.getEmail(),"email")
|
||||
// .notNull(response.getAmountMin(),"amountMin")
|
||||
// .notNull(response.getStartTime(),"startTime")
|
||||
// .notNull(response.getEndTime(),"endTime")
|
||||
.notNull(response.getAmountMin(),"amountMin")
|
||||
.notNull(response.getStartTime(),"startTime")
|
||||
.notNull(response.getEndTime(),"endTime")
|
||||
.notNull(response.getDocumentationRequested(), "documentationRequested")
|
||||
.notEmpty(response.getAimedTo(), "aimedTo")
|
||||
.notEmpty(response.getCriteria(), "criteria")
|
||||
|
||||
@@ -66,7 +66,9 @@ public class DateTimeUtil {
|
||||
|
||||
public static LocalTime parseTime(String timeString) throws DateTimeParseException {
|
||||
DateTimeFormatter formatter;
|
||||
|
||||
if(timeString==null) {
|
||||
return null;
|
||||
}
|
||||
if (!TIME_PATTERN.matcher(timeString).matches()) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,"Invalid time format: " + timeString);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user