Choosing a validation check for a field
A test matched to the field: range for age, length and type for PIN, presence for name, format for dates or postcodes, check digit for ISBN. Always justify the choice.
Understanding Choosing a validation check for a field in IGCSE Computer Science Paper 2
What it does: Length check tests the number of characters and type check tests they are digits, which together cover the PIN rules. A check digit is calculated from the other digits and recalculated to detect mistyped or swapped digits in ISBNs and barcodes. A format check tests that data follows a set pattern. Dates and postcodes have a fixed layout, so a format check suits them. A good justification links the check to what the field must contain. Here the data is a number with a lower and upper limit, so a range check is correct.
Common mistakes: A range check on age rejects a value that is too low OR too high. No number is both below 0 and above 120, so AND never rejects anything. It should be OR. A length check must count the characters with LENGTH(PIN). Comparing PIN itself with 4 tests the value, not how many characters it has. It should be WHILE LENGTH(PIN) <> 4 DO.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 60–70) and word search (Modules 47–70).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
validation checkFill in the Blanks
Spot the Error
Student with a class code? Join your class →