mattmat 1
This commit is contained in:
parent
005776e61a
commit
e8a2a3a19d
3 changed files with 20 additions and 15 deletions
|
|
@ -146,6 +146,18 @@ public class ValidationService {
|
|||
|
||||
}
|
||||
|
||||
private <R extends BaseRequest, T extends RequestParameters> Map<String, Boolean> getRulesForEmptyDates(R request, T parameters) {
|
||||
Boolean emptyDatesAllowed = validateEmptyDates(request, parameters);
|
||||
|
||||
if (!emptyDatesAllowed && parameters.getStartDate() != null && parameters.getEndDate() != null) {
|
||||
if (parameters.getStartDate().isAfter(parameters.getEndDate())) {
|
||||
throw new IllegalArgumentException("eks.error.date.order");
|
||||
}
|
||||
}
|
||||
|
||||
return Map.of(ValidationService.IS_EMPTY_DATES_ALLOWED, emptyDatesAllowed);
|
||||
}
|
||||
|
||||
private static <T extends RequestParameters> Boolean validateEmptyDates(BaseRequest request, T parameters) {
|
||||
if (request.getRequestValidationRules() == null) {
|
||||
return Boolean.FALSE;
|
||||
|
|
@ -154,22 +166,11 @@ public class ValidationService {
|
|||
LocalDate startDate = parameters.getStartDate();
|
||||
LocalDate endDate = parameters.getEndDate();
|
||||
if (Boolean.FALSE.equals(emptyDatesAllowed) && (startDate == null || endDate == null)) {
|
||||
throw new IllegalRequestParametersException("пустые даты не допускаются");
|
||||
throw new IllegalRequestParametersException("eks.error.date.empty");
|
||||
}
|
||||
return emptyDatesAllowed;
|
||||
}
|
||||
|
||||
private <R extends BaseRequest, T extends RequestParameters> Map<String, Boolean> getRulesForEmptyDates(R request, T parameters) {
|
||||
Boolean emptyDatesAllowed = validateEmptyDates(request, parameters);
|
||||
if (!emptyDatesAllowed && parameters.getStartDate() != null && parameters.getEndDate() != null) {
|
||||
if (parameters.getStartDate().isAfter(parameters.getEndDate())) {
|
||||
throw new IllegalArgumentException("Start date must be before end date");
|
||||
}
|
||||
}
|
||||
|
||||
return Map.of(ValidationService.IS_EMPTY_DATES_ALLOWED, emptyDatesAllowed);
|
||||
}
|
||||
|
||||
public <T> Map<String, String> validateByValidationConfig(List<String> ids, T c) throws ValidationException, FileNotFoundException, SQLException {
|
||||
|
||||
ValidationRules config = configService.getConfig(ConfigType.VALIDATE_BLOCK, ValidationRules.class);
|
||||
|
|
@ -193,7 +194,7 @@ public class ValidationService {
|
|||
.toList();
|
||||
|
||||
if (!invalidColumns.isEmpty()) {
|
||||
String message = "Запись " + id + " не удовлетворяет критериям валидации.";
|
||||
String message = "Запись " + id + " имеет не отменённые временные меры или подписанные повестки";
|
||||
invalidRecords.put(id, message);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue