O Level Computer Science (2210)

Algorithm design and problem-solving

Validation and verification

Range, length, type, presence, format, and check digit checks, plus double entry and visual checks.

Examples use Cambridge pseudocode for the 2026–2028 syllabus.

Validation

Validation is an automatic check by the program that data is reasonable and meets set rules before it is accepted. It cannot tell whether the data is correct: an age of 15 passes a range check even if you are 16.

CheckMakes sure that...Example
RangeA value is between a lower and upper limitA percentage is 0 to 100
LengthData has an exact number, or a minimum/maximum number, of charactersA password is at least 8 characters
TypeData is the right data typeAn age is a whole number, not text
PresenceData has been entered and is not left blankAn email field is not empty
FormatData follows a patternA date is DD/MM/YYYY; a code is two letters then four digits
Check digitA code's final digit matches the one calculated from the othersISBNs and barcodes

A validation loop

A REPEAT ... UNTIL loop keeps asking until the input passes. This one does a range check and shows an error message each time the value is rejected.

Pseudocode
DECLARE Mark : INTEGER
REPEAT
    OUTPUT "Enter a mark from 0 to 100"
    INPUT Mark
    IF Mark < 0 OR Mark > 100
      THEN
        OUTPUT "Invalid mark, try again"
    ENDIF
UNTIL Mark >= 0 AND Mark <= 100
OUTPUT "Accepted: ", Mark

A length check

LENGTH() returns the number of characters in a string, so it is used for length checks.

Pseudocode
DECLARE Password : STRING
INPUT Password
WHILE LENGTH(Password) < 8 DO
    OUTPUT "Password must be at least 8 characters"
    INPUT Password
ENDWHILE

Verification

Verification checks that data has been copied or entered accurately, matching the original.

  • Double entry: the data is entered twice and the two entries are compared, as when you type a new password twice.
  • Visual check: the user reads the data on screen and compares it with the original document.

Key idea. Validation: is the data sensible? Verification: is the data the same as the original?

Check yourself

Which validation check ensures a field is not left blank?Show answer

A presence check.

Why can data pass validation and still be wrong?Show answer

Validation only checks data is sensible and follows the rules, not that it is the true value.

Suggest a validation check for a UK postcode such as CB2 1TN.Show answer

A format check (letters and digits in the right pattern), or a length check.

References used to build these lessons

We used these official documents as references when building this course's lessons. They are the sources for the syllabus structure and course requirements.

Cambridge International · 2210 · Exams 2026–2028