Validation and Verification Checks
1. Why Check Input Data At All?
Programs cannot assume that the data entered is sensible. Users mistype, misread instructions, or deliberately enter nonsense. If bad data reaches the processing stage, the output is wrong — and the program may crash.
Validation asks “is this data reasonable?” — done automatically by the program.
Verification asks “has this data been copied or typed accurately?” — checks for mistakes during entry.
The distinction matters because a value can pass one and fail the other. A date of birth of 14/07/2009 is perfectly valid — but if the student was actually born in 2010, it is not verified. Validation cannot detect that; only verification can.
2. Validation Checks
The syllabus requires six validation checks. Learn what each one rejects, and one example of each.
| Check | What it tests | Example |
|---|---|---|
| Range check | The value falls between a stated lower and upper limit | A month must be from 1 to 12; 13 is rejected |
| Length check | The data has an exact number, or an acceptable number, of characters | A password must be at least 8 characters |
| Type check | The data is of the required data type | Age must be an integer; "twelve" is rejected |
| Presence check | Data has actually been entered and the field is not empty | An email address cannot be left blank |
| Format check | The data follows a required pattern of characters | A date entered as dd/mm/yyyy |
| Check digit | An extra digit calculated from the others, recalculated to confirm the number was entered correctly | The final digit of a barcode or ISBN |
A range check in pseudocode
Length check versus format check
These are easy to mix up. A length check counts characters. A format check inspects the arrangement of characters.
| Data entered | Length check (must be 7) | Format check (2 letters then 5 digits) |
|---|---|---|
| AB12345 | Passes | Passes |
| 1234567 | Passes | Fails — no letters |
| AB123 | Fails — only 5 | Fails |
How a check digit works
A check digit is calculated from the other digits and stored as part of the number. When the number is entered, the program repeats the calculation and compares the result with the digit supplied. If they differ, a digit was mistyped or transposed.
- It detects a single mistyped digit
- It detects two digits swapped round (transposition), e.g. 45 typed as 54
- It detects missing or extra digits
3. Verification Checks
The syllabus requires two verification methods.
| Method | How it works | Typical use |
|---|---|---|
| Visual check | The person entering the data reads it back on screen and compares it with the original source document | Checking a typed address against a paper form |
| Double entry check | The data is entered twice and the computer compares the two versions. If they differ, at least one is wrong | Confirming a new password or email address |
4. Validation and Verification Together
Real systems use both, because they catch different problems.
| Validation | Verification | |
|---|---|---|
| Question asked | Is the data reasonable? | Was the data entered accurately? |
| Performed by | The program, automatically | The user, or the program comparing two entries |
| Catches | Impossible or badly formed values | Typing and copying mistakes |
| Misses | Wrong but plausible values | Values that are accurately copied but nonsensical |
5. Exam Focus
Quick self-check
- State the difference between validation and verification in one sentence each.
- Name the six validation checks.
- Give a value that passes a length check but fails a format check.
- Explain one situation a double entry check fails to detect.
- A field must contain a percentage. Name two suitable validation checks and state what each rejects.