diff --git a/src/main/java/org/sunbird/common/util/ProjectUtil.java b/src/main/java/org/sunbird/common/util/ProjectUtil.java index f637d32d5..61a65ec29 100644 --- a/src/main/java/org/sunbird/common/util/ProjectUtil.java +++ b/src/main/java/org/sunbird/common/util/ProjectUtil.java @@ -155,7 +155,7 @@ public static Boolean validateExternalSystemId(String externalSystemId) { } public static Boolean validateExternalSystem(String externalSystem) { - return externalSystem.matches("[a-zA-Z ]{0,255}$"); + return externalSystem.matches("^(?=.*[a-zA-Z .-])[a-zA-Z0-9 .-]{1,255}$"); // Allow only alphanumeric, alphabets and restrict if only numeric character } public static void updateErrorDetails(SBApiResponse response, String errMsg, HttpStatus responseCode) { @@ -198,4 +198,8 @@ public static Boolean validateDate(String dateString){ } return false; } + + public static Boolean validateEmployeeId(String employeeId) { + return employeeId.matches("^(?=.*\\d|[a-zA-Z]{30})[a-zA-Z0-9 .-]{1,30}$"); // Allow only alphanumeric, numeric and restrict if only alphabets character + } } \ No newline at end of file diff --git a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java index ffd73089f..53942940c 100644 --- a/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java +++ b/src/main/java/org/sunbird/profile/service/UserBulkUploadService.java @@ -238,6 +238,11 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx } else { invalidErrList.add("Invalid value for Employee ID column type. Expecting string/number format"); } + if (StringUtils.isNotBlank(userRegistration.getEmployeeId())) { + if (!ProjectUtil.validateEmployeeId(userRegistration.getEmployeeId())) { + invalidErrList.add("Invalid Employee ID : Employee ID can contain alphanumeric characters or numeric character and have a max length of 30"); + } + } } if (nextRow.getCell(10) != null && nextRow.getCell(10).getCellType() != CellType.BLANK) { if (nextRow.getCell(10).getCellType() == CellType.NUMERIC) { @@ -267,7 +272,7 @@ private void processBulkUpload(HashMap inputDataMap) throws IOEx if (nextRow.getCell(12).getCellType() == CellType.STRING) { userRegistration.setExternalSystem(nextRow.getCell(12).getStringCellValue().trim()); if (!ProjectUtil.validateExternalSystem(userRegistration.getExternalSystem())) { - invalidErrList.add("Invalid External System : External System Name can contain only alphabets and can have a max length of 255"); + invalidErrList.add("Invalid External System Name : External System Name can contain only alphabets and alphanumeric and can have a max length of 255"); } } else { invalidErrList.add("Invalid value for External System Name column type. Expecting string format");