Validation checks that data is reasonable and allowed. Verification checks that data is the same as the original or the intended value. They answer two different questions, and exam questions often ask you to explain the difference or name which one a scenario describes.
This lesson builds on choosing a validation rule and sits in the validation, verification and testing module.
What question does each one answer?
| Validation | Verification | |
|---|---|---|
| Question | Is this data acceptable? | Is this data what was meant? |
| Done by | The program, automatically | A person or a comparison step |
| Example | Age must be 13 to 17 | Type the email twice and compare |
| Can it catch a wrong value inside the limits? | No | Yes |
Two common verification methods are double entry (enter the data twice and compare) and a visual check (a person reads the entered data and compares it with the source).
Worked example
A fictional club form is filled in from a paper sheet. The sheet says the member’s age is 15.
One typist presses the wrong key and enters 51. Another typist enters 16 on a different form where the true age is also 15.
Step 1, apply the range check (13 to 17).
| Typed | True age | Passes range check? |
|---|---|---|
| 51 | 15 | No, 51 > 17, so it is rejected |
| 16 | 15 | Yes, 13 <= 16 <= 17 |
Step 2, see what validation did. It caught 51. It could not catch 16, because 16 is reasonable and allowed.
Step 3, apply verification. If the form is entered twice, the first copy says 16 and the second says 15. The comparison finds a mismatch and the typist checks the paper sheet. A visual check against the sheet would also find it.
Conclusion: both are used together. Validation removes impossible values quickly. Verification catches the possible but wrong ones.
A short double-entry comparison in pseudocode:
INPUT FirstEntry
INPUT SecondEntry
IF FirstEntry = SecondEntry THEN
OUTPUT "Entries match"
ELSE
OUTPUT "Entries differ, please check the source"
ENDIF
With FirstEntry = 16 and SecondEntry = 15 the condition is FALSE, so the output is “Entries differ, please check the source”.
The mistake to watch for
Mistaken answer: “Validation makes sure the data entered is correct.”
The student treated “valid” as meaning “true”.
Validation only makes sure the data is reasonable. A wrong value that fits the rules passes. Write “reasonable and allowed” or “sensible and within the rules”, and use verification when the idea is matching the source.
Check yourself
1. A program rejects a quantity of -3. Is this validation or verification?
Show answer
Validation. The program automatically decided that -3 is not an allowed quantity.
2. A user types a new password twice and the program compares them. Name the type of check and the method.
Show answer
Verification, by double entry.
3. A form accepts 2012 as a birth year, but the real year was 2021. Which check could still pass it, and which could catch it?
Show answer
A range check could pass it, because 2012 is reasonable. A verification step, such as comparing with the source document, could catch it.
Where does this lead next?
Next, learn to design normal, boundary and invalid test data so you can check that a validation rule really works. You can practise both ideas in the mixed practice set.
If the two words keep swapping in your answers, that is something we work on in online one-to-one Computer Science tuition.