cs-053 — The Validator Trio

FieldValue
idcs-053
difficultyBeginner
topicsfunctions, reuse
lecturelecture-14
estimated time5-minute attempt + 10-minute discussion
prerequisitesnone
objectivestate inputs, outputs, and assumptions, then solve a small instance by hand
solutionheld by the instructor; discussed after the attempt

Problem

Three validation checks (email-ish, phone-ish, id format) become three functions plus a driver. Naming, single purpose, return vs print.

Your deliverable is the function list with contracts, the composed driver, and one input per function that exercises its edge. If the problem is ambiguous anywhere, state the assumption you are making and carry on — a stated assumption is part of a good answer.

Examples

Solve for the worked instance first. Then ask what would change if one number, name, or condition were replaced by something stranger.

What to notice

Discussion starter

After the solution is revealed, the class spends five minutes on this prompt: "Where would this decomposition crack if the input format changed?"

Constraints and assumptions

Hints and extension