EasyJavaScriptTypeScript

Validate Email Input

TypeScriptSecurityInput Validation

The signup form below accepts any string as an email address without validation.

The bug: malformed input flows downstream into emails, database records and third-party APIs — at best causing bounced emails, at worst becoming an injection vector in systems that trust the "email" field is actually shaped like one.

Your task: fix solve(email) to return true only for strings shaped like local@domain.tld (non-empty local part, @, non-empty domain, a dot, non-empty TLD) — false otherwise.

Sample tests

Test #1Valid email
Input: ["alice@example.com"]
Output: true
Test #2No @ at all
Input: ["not-an-email"]
Output: false
Test #3Missing TLD
Input: ["a@b"]
Output: false