Lesson 66: Check it twice
Validation or verification?
- Validation checks that data is sensible: a range check, a length check, a type check (lesson 40).
- Verification checks that data was entered correctly: it is what the user meant to type.
- A password "cat12" can pass validation but still be a typing mistake. Verification catches that.
| Check | How it works |
|---|---|
| double entry | type the data twice; accept it only if both are the same |
| visual check | show the data again; the user looks and confirms it |
In the exam
- 0478/21/M/J/25 Q2(b): describe one verification check for a new password. Mark scheme: visual check: look at the data entered and confirm it matches; or double entry check: enter the data twice and only accept identical values.
- 0478/22/M/J/23 Q4(b): (i) a double entry check is used for verification. (ii) Write the code. Mark scheme: iteration; two inputs; check that the two inputs are the same; repeat until they match.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
A double entry check: the user types a new password twice. The program keeps the first one in first. Finish the part for the second entry: if both are the same, print Password saved and light the green LED (pin 12). If not, print Passwords do not match, light the red LED (pin 13) and ask again with Enter a new password.
Click Run to see the output here.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
A visual check: after the user types a room number, show it back and ask You typed 42. Correct? (Y/N). If the answer is Y, print Saved: and the number. If not, ask for the room number again.
Click Run to see the output here.