← IGCSE Computer Science Paper 2

Choosing a validation check for each field

A rule that tests data on entry. Pick the one that fits each field: range for a mark, length for a phone number, presence for a required name, list for a year group.

Understanding Choosing a validation check for each field in IGCSE Computer Science Paper 2

What it does: A presence check only tests that something has been entered, which is exactly what a required name needs. Age is a number with a lowest and highest allowed value, so a range check fits. Listing every allowed age would be longer and less suitable. A mark has a sensible minimum and maximum, so a range check is the best fit and rejects values such as 150 or -5. A phone number always has a fixed number of digits, so a length check catches numbers that are too short or too long.

Common mistakes: A mark is a number that must fall between limits, so it needs a range check. A length check counts characters and does not test the size of a value. It should be 'Check: range check'. A length check should reject a phone number whose length is wrong. Using = would show the error for valid numbers. It should be IF LEN(Phone) <> 11 THEN.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

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 500–522) and word search (Modules 500–538).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which validation check best fits a Mark field that must be between 0 and 100?
Presence checkRange check
Matches
Validation for Mark: presence check
↓
A presence check only confirms that something was typed, so it would accept a mark of 500. A range check from 0 to 100 should be used.
Applying
Meanings
Term
validation check
Meaning
A rule that tests data on entry. Pick the one that fits each field: range for a mark, length for a phone number, presence for a required name, list for a year group.
Practice
Mark: range check, 0 to 100
Testing
Gaps
Mark: check, between 0 and 100
Check Answer
Spots
1Field: Mark (integer)
2Check: length check

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Sand Cat' badge — Precision Prowler, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which validation check best fits a Mark field that must be between 0 and 100?
A. Range check ✓
B. Presence check
A range check tests that a number lies between a lowest and highest allowed value, which suits a mark from 0 to 100.
2. A PhoneNumber field must always contain exactly 10 digits. Which check fits best?
A. Length check ✓
B. Range check
A length check tests how many characters are entered. Phone numbers are not used as quantities, so a range check is not suitable.
3. The FirstName field must not be left empty when a new student is added. Which check fits best?
A. Length check
B. Presence check ✓
A presence check makes sure that something has been entered in a required field. A length check would only test how long the data is, not whether it is there at all.
4. A YearGroup field may only contain 7, 8, 9, 10 or 11. Which check fits best?
A. List check ✓
B. Presence check
A list check (lookup check) accepts only values that appear in a set of allowed values, such as the school's year groups.
5. An Age field for students in a school must be between 11 and 18. Which check is the best choice?
A. List check
B. Range check ✓
Age is a number with a lowest and highest allowed value, so a range check fits. Listing every allowed age would be longer and less suitable.

Match the Pairs

Range check: Mark >= 0 AND Mark <= 100 → Checks a number lies between a lowest and highest allowed value, so it fits a test mark or an age
Length check: LENGTH(Phone) = 11 → Checks the data has exactly the right number of characters, so it fits a phone number
A Name field is required, so the record must not be saved with it empty. Use a presence check. → Name <> ''
A YearGroup field can only hold a few fixed values, so check it against an allowed list. → YearGroup IN (7, 8, 9, 10, 11)
Validation for Mark: presence check → A presence check only confirms that something was typed, so it would accept a mark of 500. A range check from 0 to 100 should be used.
Validation for YearGroup: length check → A length check tests the number of characters, so it cannot stop 3 or 14 being entered. A list check against the valid year groups is better.

Key Term

validation check
A rule that tests data on entry. Pick the one that fits each field: range for a mark, length for a phone number, presence for a required name, list for a year group.

Fill in the Blanks

1. Mark: range check, between 0 and 100
Hint: Type the check that tests a number lies between a lowest and highest value.
2. Phone: length check, must be 10 characters
Hint: Type the check that counts how many characters are entered.
3. FirstName: presence check, cannot be empty
Hint: Type the check that makes sure a required field has been filled in.
4. YearGroup: list check, only 7, 8, 9, 10, 11
Hint: Type the check that compares the value with a set of allowed choices.
5. IF LENGTH(Phone) = 10 THEN ACCEPT
Hint: Type the function that returns the number of characters in a value.

Spot the Error

Question 1
A Field: Mark (integer)
B Check: length check
C Rule: 0 <= Mark <= 100
Line B — A mark is a number that must fall between limits, so it needs a range check. A length check counts characters and does not test the size of a value. It should be 'Check: range check'.
Question 2
A IF LEN(Phone) = 11 THEN
B OUTPUT "Must be 11 digits"
C ENDIF
Line A — A length check should reject a phone number whose length is wrong. Using = would show the error for valid numbers. It should be IF LEN(Phone) <> 11 THEN.
Question 3
A Field: FirstName
B Check: presence check
C Rule: FirstName = ""
Line C — A presence check makes sure a required field is not empty. Using = "" would only accept an empty name. The rule should be FirstName <> "".
Question 4
A Field: YearGroup
B Check: presence check
C Rule: IN (7, 8, 9, 10, 11)
Line B — A presence check only tests that something was entered, so a wrong year such as 12 would still pass. A year group must be one of a fixed set of values, so use a list check.
Question 5
A Field: Age
B Check: length check
C Rule: Age >= 11 AND Age <= 16
D Reject if outside range
Line B — The rule tests that Age lies between 11 and 16, which is a range check. A length check only counts characters, so it would accept an age such as 99. It should be 'Check: range check'.

Student with a class code? Join your class →