Code RoomEmail regex accepts invalid addresses
MediumPrep Room Coding #1776

Email regex accepts invalid addresses

Code reviewCode quality & reviewMid–Senior~20 min

Review this JavaScript signup validation handler.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1app.post('/signup', (req, res) => {
2 const { email, bio } = req.body;
3 const emailRe = /^([a-zA-Z0-9]+)+@[a-zA-Z0-9]+\.[a-z]+$/;
4 if (!emailRe.test(email)) {
5 return res.status(400).json({ error: 'invalid email' });
6 }
7 const user = createUser({ email, bio });
8 res.status(201).json({ id: user.id });
9});
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.