BuildJuniorBackendAuto-graded
Fix signup validators that accept the wrong inputs
Five signup validators get real input wrong: stray spaces, plus-addressed emails, international phone numbers, leap days.validators.py has five validators for a signup form (email, phone, password, username, date). Each takes one value and returns True or False. In production they turn away valid input such as an international phone number, let through input they should refuse such as 2023-02-29, and raise on None. Make each one match the spec in the brief, keeping the same signature. A validator only counts if it gets every case in a hidden test set right.30 min
Python
Goals
validate_emailandvalidate_phoneaccept real addresses and numbers (plus-addressing, international numbers with separators) and reject every malformed one the spec lists.validate_passwordandvalidate_usernamefollow the spec's length and character rules: the password taken verbatim, the username trimmed first.validate_dateaccepts only real dates in strictYYYY-MM-DD, with no spaces around them, leap years included (every 4 years, except century years not divisible by 400).- No validator raises on missing input:
None, an empty string and whitespace-only text all returnFalse.
What it measures
PythonHandling messy and missing values with the standard library, without raising.
Test case designThinking of the inputs a real form sends: boundary lengths, odd formats, empty fields.
Balanced judgementAccepting the valid input users really type while still rejecting what the spec forbids.
Your environment
Terminal + editorA full shell in the browser
Coding agentAlready signed in, no API key to set up
Isolated workspaceOnly yours, wiped when you finish
Start this lab
30 min
Start labYou'll need to sign in to Anthropos first. The lab opens in a private cloud workspace with your coding agent ready to use.AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo