private void validateChangeMSISDNRequest(ChangeMsisdnRequest request, Errors errors) { if (request == null || isBlank(request.getFlwId()) || FrontLineWorker.DEFAULT_UUID_STRING.equals(request.getFlwId())) return; FrontLineWorker frontLineWorker = allFrontLineWorkers.getByFlwId(UUID.fromString(request.getFlwId())); if (frontLineWorker == null) { errors.add("FrontLine worker with id in newMsisdn section not found"); return; } if (!frontLineWorker.getMsisdn().equals(PhoneNumber.formatPhoneNumber(request.getMsisdn()))) { errors.add("Frontline worker with new msisdn and id does not exist"); } }
private void validateSuccessfulVerification( FrontLineWorkerVerificationRequest request, Errors errors) { if (request.getDesignation() == null) { errors.add("designation field has invalid/blank value"); } if (isBlank(request.getName()) || !Pattern.matches("[a-zA-Z0-9\\s\\.]*", request.getName())) { errors.add("name field has invalid/blank value"); } new WebRequestValidator().validateLocation(request.getLocation(), errors); if (request.getReason() != null) { errors.add("reason field should not be a part of the request"); } validateChangeMSISDNRequest(request.getChangeMsisdnRequest(), errors); }
private void validateInvalidOtherRequest( FrontLineWorkerVerificationRequest request, Errors errors) { if (isBlank(request.getReason())) { errors.add("reason field has blank value"); } if (request.getName() != null) { errors.add("name field should not be a part of the request"); } if (request.getLocation() != null) { errors.add("location field should not be a part of the request"); } if (request.getDesignation() != null) { errors.add("designation field should not be a part of the request"); } }
private void validateNoOtherFLWExistsWithSameMsisdnAndStatus( FrontLineWorkerVerificationRequest request, Errors errors) { List<FrontLineWorker> flwWithSameMsisdnAndWithSomeStatus = allFrontLineWorkers.getByMsisdnWithStatus(request.getMsisdn()); if (flwWithSameMsisdnAndWithSomeStatus.size() == 1 && !flwWithSameMsisdnAndWithSomeStatus.get(0).getFlwId().equals(request.getFlwId()) && !request.isDummyFlwId()) errors.add("Conflicting flw record exists. Please try again later."); }