// ID Validation static boolean isValidEmployeeId(Long empId) { String regex = "^[1-9]\d{5,6}$"; String empIdString = String.valueOf(empId); return empIdString.matches(regex); }
// Email Validation static boolean isValidEmployeeEmail(String empEmail) { String regex = "^[a-zA-Z0-9](?:[a-zA-Z0-9._-]{0,62}[a-zA-Z0-9])?@[a-zA-Z0-9]+(?:\\.[a-zA-Z0-9]+)*$"; return empEmail.matches(regex); } // Password Validation static boolean isValidEmployeePassword(String empPassword) { String regex = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#])(?=\\S+$).{8,20}$"; return empPassword.matches(regex); } // PhoneNo Validation static boolean isValidEmployeePhoneNo(Long empPhoneNo) { String regex = "^(?!([0-9])\\1{9})\\d{10}$"; String empPhoneNoString = String.valueOf(empPhoneNo); return empPhoneNoString.matches(regex); } // DOB Validation static boolean isValidEmployeeAge(Integer age) { return age >= 18 && age < 45; } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
// ID Validation
static boolean isValidEmployeeId(Long empId) {
String regex = "^[1-9]\d{5,6}$";
String empIdString = String.valueOf(empId);
return empIdString.matches(regex);
}