remove null checks for call and put some other validation

This commit is contained in:
rajesh
2024-08-28 17:44:20 +05:30
parent 88e019350a
commit 75db09eb12
15 changed files with 134 additions and 104 deletions

View File

@@ -1,7 +1,13 @@
package net.gepafin.tendermanagement.service.impl;
import java.time.LocalDate;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.response.CallResponse;
import net.gepafin.tendermanagement.util.FieldValidator;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
public class CallValidatorServiceImpl {
@@ -11,8 +17,8 @@ public class CallValidatorServiceImpl {
.notNull(response.getName(), "name")
.notNull(response.getDescriptionShort(), "descriptionShort")
.notNull(response.getDescriptionLong(), "descriptionLong")
.notNull(response.getStartDate(), "startDate")
.notNull(response.getEndDate(), "endDate")
.notNull(response.getDates().get(0), "startDate")
.notNull(response.getDates().get(1), "endDate")
.notNull(response.getStatus(), "status")
.notNull(response.getRegionId(), "regionId")
.notNull(response.getAmount(), "amount")
@@ -26,6 +32,13 @@ public class CallValidatorServiceImpl {
.notEmpty(response.getImages(), "images")
.notEmpty(response.getCheckList(), "checkList")
.validate();
if (response.getDates().get(0).toLocalDate().isBefore(LocalDate.now())
|| response.getDates().get(1).toLocalDate().isBefore(LocalDate.now()) ||
response.getDates().get(0).toLocalDate().isAfter(response.getDates().get(1).toLocalDate())) {
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
}
}
}