Cambridge IGCSE · Topic 7 (5-6)
IGCSE Computer Science 0478 / Topic 7 / IGCSE

Sensible is not the same as correct.

Programs must not accept nonsense such as an age of 250 or an empty name. Validation checks make the computer reject data that breaks the rules. Verification checks that data was copied in exactly as intended. You need to name, describe and write both.

The key idea

Validation is an automatic check by the computer that input data is sensible and allowed before it is accepted: range, length, type, presence, format and check digit checks. Verification checks that data has been entered accurately, matching the original: a visual check or a double entry check. Validation cannot prove data is correct, only that it is reasonable.

Data is entered Validation (automatic) Is the data sensible and allowed? range, length, type, presence, format, check digit Verification Was it copied in exactly as intended? visual check, double entry check
Fig. 1: validation asks whether data is allowed; verification asks whether it was entered as intended
Section 01

Six validation checks.

Type different values into the validation tab of the lab and see which check accepts or rejects each one. Notice that the computer does the checking, with no person involved.

CheckWhat it testsExample
RangeA value is between a lower and an upper limitA mark is from 0 to 100
LengthThe number of characters is exactly, at least or at most a set numberA password has at least 8 characters
TypeThe data is the right data typeThe number of tickets is an integer, not "two"
PresenceSomething has been entered; the field is not emptyA surname must be given
FormatThe data follows a set pattern of charactersA date is DD/MM/YYYY; a code is two letters then four digits
Check digitThe final digit, calculated from the others, still matchesThe last digit of an ISBN-13 or a barcode
// range check: keep asking until the value is allowed
REPEAT
    OUTPUT "Enter the number of tickets (1 to 6)"
    INPUT Tickets
    IF Tickets < 1 OR Tickets > 6
      THEN
        OUTPUT "Error: enter a number from 1 to 6"
    ENDIF
UNTIL Tickets >= 1 AND Tickets <= 6

// length check
REPEAT
    OUTPUT "Enter a password of at least 8 characters"
    INPUT Password
UNTIL LENGTH(Password) >= 8

// presence check
OUTPUT "Enter your surname"
INPUT Surname
WHILE Surname = "" DO
    OUTPUT "Surname must not be empty. Enter your surname"
    INPUT Surname
ENDWHILE
Examiner trap

A range check is about the value (13 is too big); a length check is about the number of characters ("abc" is too short). Name the check that matches the rule in the question.

Section 02

Check digits.

A check digit is an extra digit worked out from the other digits and added to the end. When the number is entered later, the computer recalculates it; if the result differs, a digit was typed wrongly or two digits were swapped.

Worked example ISBN-13 check digit
Calculate the check digit for the first 12 digits of an ISBN: 978123456789.
  1. Multiply the digits alternately by 1 and 3: 9×1, 7×3, 8×1, 1×3, 2×1, 3×3, 4×1, 5×3, 6×1, 7×3, 8×1, 9×3.
  2. Products: 9, 21, 8, 3, 2, 9, 4, 15, 6, 21, 8, 27. Their sum is 133.
  3. Divide by 10 and take the remainder: 133 MOD 10 = 3.
  4. Subtract from 10: 10 − 3 = 7. (If the remainder is 0, the check digit is 0.)
Answer: Check digit 7, so the full ISBN is 9781234567897
Your turn
Calculate the ISBN-13 check digit for 978014103614.
Examiner trap

A check digit is a validation check (it is calculated automatically), even though it catches typing mistakes. It cannot tell you whether the number is the right book, only that the digits are consistent.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What is validation?

Quick check+10 XP

Which check makes sure a field has not been left empty?

Quick check+10 XP

Which of these is a verification check?

Quick check+10 XP

In the lab, a range check accepts 1 to 6. Which input is rejected?

Section 03

Verification: entered as intended.

Data can pass every validation check and still be wrong: a date of birth of 12/03/2009 typed instead of 21/03/2009 is perfectly sensible. Verification catches mistakes made while copying or typing.

// double entry check
REPEAT
    OUTPUT "Enter your new password"
    INPUT Password1
    OUTPUT "Enter the password again"
    INPUT Password2
    IF Password1 <> Password2
      THEN
        OUTPUT "The passwords do not match. Try again"
    ENDIF
UNTIL Password1 = Password2
Examiner trap

Validation and verification are not interchangeable. Validation: is the data reasonable? Verification: is it the same as the original? Neither guarantees the data is true.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to IGCSE Paper 1 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

A product code must be two capital letters followed by four digits, e.g. KT2093. Which check is the most suitable?

Exam style+20 XP

Why can validation not guarantee that data is correct?

Exam style+20 XP

The first 12 digits of an ISBN-13 give a weighted sum of 120. What is the check digit?

Exam style+20 XP

Which pseudocode statement is a length check?

Skill unlocked

Validation and verification, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
The six validation checks, check digits, visual and double entry verification, and writing validation in pseudocode.