Validation checks that data is reasonable and follows a rule. Verification checks that the data entered is the data the user really meant. Both protect a program, but they catch different kinds of error.
This lesson belongs to algorithm reasoning and test design. It builds on the idea of invalid data from choosing normal, boundary and invalid test data.
What is the classroom program?
A class uses a small program to register students for a science fair. It asks for the student’s form number, which must be 1 to 5, and then for a class code chosen by the student.
The program asks for the form number once, and asks for the class code twice. Those two behaviours show the two ideas.
Which step is validation?
The form number check is validation. The program tests the value against a rule:
INPUT form
WHILE form < 1 OR form > 5
OUTPUT "Enter a form from 1 to 5"
INPUT form
END WHILE
The program does not know the true form. It only knows that 9 or 0 is impossible and refuses it. A value of 4 from a Form 3 student would still be accepted.
Which step is verification?
The class code entered twice is verification. The program compares the two entries:
INPUT code1
INPUT code2
IF code1 <> code2 THEN
OUTPUT "Codes do not match"
END IF
Here the program cannot judge whether the code is sensible. It only checks that the student typed the same thing both times, which reduces the chance of a slip.
How do you keep them apart?
Ask what each check is protecting.
| Question | Validation | Verification |
|---|---|---|
| What does it check? | Data follows a rule | Data matches the intended value |
| Examples | Range, length, type, presence | Entering twice, reading back |
| What can it miss? | A sensible but wrong value | A value that breaks the rule in both entries |
A common mistake is to call double entry “validation because it checks the input”. The word to watch is intended. Double entry checks accuracy against what the user meant, so it is verification.
Check yourself
A school library program asks for a book’s ISBN. It rejects any entry that is not exactly 13 digits, then shows the typed number on screen and asks the student to confirm it. Name the validation step and the verification step.
Answer
The rule “exactly 13 digits” is validation, specifically a length check together with a type check for digits.
Showing the number back and asking for confirmation is verification. It lets the student notice a wrong digit that still satisfied the 13-digit rule.
What to study next
Move on to the integrated algorithm reasoning and test design practice, or review your own slips with the mistake log and paper-error review.
If you would like a teacher to test your wording on exam-style answers, see online one-to-one Computer Science tuition.