Paper 2 · Validation
The validation checks Paper 2 actually asks for
· 6 min read · For students
Validation asks “is this data reasonable?”. Verification asks “was it copied correctly?”. They are different marks. A range check does not prove two people typed the same number, and a double entry does not prove the number is allowed.
The six names to learn
| Check | The question it answers | In pseudocode |
|---|---|---|
| Range | Is the number inside the allowed limits? | Mark >= 0 AND Mark <= 100 |
| Length | Is the text the right number of characters? | LENGTH(Code) = 6 |
| Type | Is it a whole number, a decimal, or text? | The DECLARE type, and what INPUT will accept |
| Presence | Did they type anything at all? | LENGTH(Name) > 0 |
| Format | Does it match a pattern, such as two letters then four digits? | Check each character in turn |
| Check digit | Does a calculated digit match the last character? | A total, a remainder, then a comparison |
You will not write all six in one question. You do need to know which name belongs to which test, because the question says “a range check” and expects the condition, not a paragraph.
A range check keeps asking
The usual wrapper is REPEAT … UNTIL the value is acceptable. The condition on UNTIL is the success, so it is the opposite of the error you are rejecting.
DECLARE Mark : INTEGER
INPUT Mark
IF Mark = INTEGER THEN
OUTPUT "Whole number"
ENDIFDECLARE Mark : INTEGER
INPUT Mark
IF Mark >= 0 AND Mark <= 100 THEN
OUTPUT "Valid"
ELSE
OUTPUT "Invalid"
ENDIFValid
To keep reading until the mark is valid, the same test moves onto the UNTIL line:
DECLARE Mark : INTEGER
REPEAT
OUTPUT "Enter a mark from 0 to 100"
INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100
OUTPUT MarkEnter a mark from 0 to 100 60
Presence is the same shape with a string: repeat until LENGTH(Name) > 0. The walk-through is the validation lesson and the presence check. LENGTH itself is in string functions.
Check your own code
Run it in the compiler. A mistake is explained in plain English, and many of them have a one-click fix.
More from the blog
- How to fill a trace table the way the mark scheme doesFor students
- Cambridge arrays start at 1For students
- The first character of a string is position 1For students