Data Validation
Practise Data Validation for GCSE Computer Science with this free worksheet and full mark scheme — Foundation and Higher exam-style questions with worked answers for AQA GCSE Computer Science (8525). Validation checks that input is sensible, using checks such as range, type, length and presence.
Free downloads
These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.
Topic overview
Data validation checks that input is sensible and in the expected format before the program uses it.
Several check types must be known. A range check confirms a value falls between limits, such as an age between 0 and 120. A length check confirms a string has an acceptable number of characters. A presence check confirms something was entered at all. A format check confirms the input matches a required pattern, such as a postcode. A lookup or type check confirms the value is one of a permitted set, or of the right data type.
The crucial limitation is that validation cannot confirm the data is correct, only that it is reasonable. An age of 35 entered for a 34-year-old passes every check but is still wrong.
Revision notes
The check types
Range check: the value falls between set limits. Length check: the string has an acceptable number of characters.
Presence check: something was entered. Format check: the input matches a required pattern. Type check: the value is of the expected data type. Lookup check: the value is one of a permitted list.
Choosing the right check
Match the check to what could plausibly go wrong with that field.
Age needs a range check; a password needs a length check; an email needs a format check. Questions usually give a field and ask which check applies and why.
The limitation
Validation confirms data is reasonable, not that it is correct.
An age of 35 entered for a 34-year-old passes every check. Only verification, such as double entry or checking against a trusted source, can address correctness.
Key points
- Validation checks input is sensible.
- A range check confirms values fall between limits.
- A length check confirms character count.
- A presence check confirms something was entered.
- A format check confirms a required pattern.
- Validation cannot confirm data is correct.
Worked examples
Example 1
State the most appropriate validation check for a person's age and explain. [2 marks]
Working
Example 2
Explain why validation cannot guarantee data is correct. [2 marks]
Working
Example 3
State the check that confirms a password is at least 8 characters. [1 mark]
Working
Common mistakes
Naming a check without justifying it.
Say why that check suits the field.
Saying validation guarantees correct data.
It only confirms the data is reasonable.
Confusing range and length checks.
Range applies to values; length applies to character counts.
Using only one type of check.
Several are examinable and different fields need different ones.
Exam tips
- Match the check to what could go wrong with that field.
- Always justify your choice of check.
- State the reasonable-not-correct limitation.
- Learn all the check types by name.
Key terms
- Validation
- Checking input is sensible and correctly formatted.
- Range check
- Confirming a value falls between limits.
- Presence check
- Confirming something was entered.
- Format check
- Confirming input matches a required pattern.
Related topics
Written and reviewed against the current AQA specification. Spotted an error? Let us know.