DEV Community

Discussion on: What even is an Open Source Program Office - with Spotify, Aiven & Wipro

Collapse
 
xmachli profile image
XMachli

// 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;
    }
}
Enter fullscreen mode Exit fullscreen mode