Task: Implement a PasswordValidator with strict validation rules
What to implement
Create a class PasswordValidator in package com.mkyong.regex with a public method:
public boolean validate(String password)
The method should return true if the password meets all required criteria, and false otherwise.
Exact requirements that must be satisfied (to make tests pass)
Password must be at least 6 characters long.
Must contain at least one lowercase letter (a-z).
Must contain at least one uppercase letter (A-Z).
Must contain at least one digit (0-9).
Must contain at least one special character from the allowed set: @, #, $, %, ^, &, +, =
Characters outside the above categories should not count toward the “special” requirement. (e.g., a star '*' should not satisfy the special character requirement.)
The implementation should be resilient to null input (return false if password is null).
How to place the solution
Put the code under /app/ in the repository, matching the package path:
/app/com/mkyong/regex/PasswordValidator.java
Notes and rationale
The provided tests expect the following behavior:
Valid examples like "mkyong1A@" and "mkYOn12$" pass (have lower, upper, digit, and a valid special).
Invalid examples such as "mY1A@" (too short), "mkyong12@" (no uppercase), "mkyoNg12*" (uses '*' which is not in the allowed set), "mkyonG$$" (no digit), and "MKYONG12$" (no lowercase) fail.
Implementing the rules as described will satisfy the test cases and reflect typical password policy checks.
Acceptance criteria
After adding PasswordValidator with the validate implementation, all tests in the provided test suite should pass.