What you're building
A Validator class that checks whether an email address is well-formed and whether a password meets strength requirements — the exact logic that guards every user registration form on the web.
Requirements
isValidEmail(email)— returnstrueif the string contains exactly one@, at least one character before it, and a domain with at least one dot and characters after the dot. Returnsfalseotherwise.isStrongPassword(password)— returnstrueif the password is at least 8 characters long, contains at least one uppercase letter, one lowercase letter, one digit, and one special character from!@#$%^&*. Returnsfalseotherwise.validate(email, password)— returns{ emailOk: boolean, passwordOk: boolean, ok: boolean }whereokistrueonly when both pass.
Stretch goals
- Add a
reasonsarray to thevalidateresult listing what failed (e.g."password too short"). - Support a configurable minimum password length via the constructor.
- Reject emails with consecutive dots or a dot immediately before
@.
What this proves
Regex literacy, boolean composition, and defensive input handling — core skills for any frontend or backend role. Interviewers love seeing clean, testable validator logic.
⚡ 40 XP
solution.jsRuns in your browser
Loading editor…
Tests4 to pass
valid email passes
invalid emails fail
strong password passes
weak passwords fail
Run your code to check these.