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

CheckThe question it answersIn pseudocode
RangeIs the number inside the allowed limits?Mark >= 0 AND Mark <= 100
LengthIs the text the right number of characters?LENGTH(Code) = 6
TypeIs it a whole number, a decimal, or text?The DECLARE type, and what INPUT will accept
PresenceDid they type anything at all?LENGTH(Name) > 0
FormatDoes it match a pattern, such as two letters then four digits?Check each character in turn
Check digitDoes 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.

WrongINTEGER is a type, not a value you can compare with.
DECLARE Mark : INTEGER
INPUT Mark
IF Mark = INTEGER THEN
    OUTPUT "Whole number"
ENDIF
RightTry it and type a mark. 60 is inside 0 to 100.
DECLARE Mark : INTEGER
INPUT Mark
IF Mark >= 0 AND Mark <= 100 THEN
    OUTPUT "Valid"
ELSE
    OUTPUT "Invalid"
ENDIF
Output
Valid

To keep reading until the mark is valid, the same test moves onto the UNTIL line:

Right
DECLARE Mark : INTEGER
REPEAT
    OUTPUT "Enter a mark from 0 to 100"
    INPUT Mark
UNTIL Mark >= 0 AND Mark <= 100
OUTPUT Mark
Output
Enter 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