This topic summary covers Knowledge Organiser: Input Validation within Input Validation for GCSE Computer Science. Revise Input Validation in 3.2 Programming for GCSE Computer Science with 15 exam-style questions and 8 flashcards. This topic shows up very often in GCSE exams, so students should be able to explain it clearly, not just recognise the term. It is section 6 of 6 in this topic. Use this topic summary to connect the idea to the wider topic before moving on to questions and flashcards.
Knowledge Organiser: Input Validation
Key Terms
- Validation: Checking that data is acceptable and sensible before processing
- Range check: Ensures a value is within a minimum and maximum (e.g. age 0–120)
- Type check: Ensures data is the correct data type (e.g. integer, not text)
- Length check: Ensures data has the required number of characters
- Presence check: Ensures a required field is not left empty
- Format check: Ensures data matches an expected pattern (e.g. postcode format)
- Check digit: A calculated digit appended to data to detect errors (e.g. barcode)
Must-Know Facts
- Validation ensures data is sensible — it does NOT guarantee data is correct or accurate
- A user can enter a valid but wrong value (e.g. wrong age that still passes a range check)
- Validation ≠ Verification: verification checks data is what the user intended (e.g. entering twice)
- Multiple validation types can be applied to a single field
- Validation prevents programs from crashing due to unexpected input
Key Concepts
- Memory aid: RPTFL-C — Range, Presence, Type, Format, Length, Check digit
- Range check:
if age >= 0 AND age <= 120 then accept endif - Presence check:
if email != "" then accept endif - Length check:
if password.length >= 8 then accept endif
Common Mistakes
- Saying validation guarantees data is correct: Validation only checks data is acceptable/sensible — a user can enter a valid but wrong value (e.g. wrong date of birth that passes a range check)
- Confusing validation with verification: Validation checks data meets rules; verification checks data matches what the user intended (e.g. typing a password twice to confirm)
- Applying the wrong validation type to a scenario: A postcode needs a format check (pattern); an age field needs a range check (min/max) — match the check to the data type
- Forgetting the presence check: Presence check is a separate type — leaving a required field empty should trigger it, not a range or type check
- Describing validation as "stopping hackers": Validation primarily prevents program crashes from unexpected input; sanitisation (not validation) specifically prevents injection attacks
Practice questions for Input Validation
A program asks the user to enter a score between 1 and 10. Which validation check should be used to ensure the number is within this range?
A registration form collects a username. The username must: not be blank, contain only letters and numbers, and be between 6 and 20 characters long. Identify three validation checks and explain what each one does for this input.