Skip to main content
✅ Validators & Form Logic

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) — returns true if the string contains exactly one @, at least one character before it, and a domain with at least one dot and characters after the dot. Returns false otherwise.
  • isStrongPassword(password) — returns true if the password is at least 8 characters long, contains at least one uppercase letter, one lowercase letter, one digit, and one special character from !@#$%^&*. Returns false otherwise.
  • validate(email, password) — returns { emailOk: boolean, passwordOk: boolean, ok: boolean } where ok is true only when both pass.

Stretch goals

  • Add a reasons array to the validate result 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.