Cambridge O Level Computer Science · Syllabus 2210 · Algorithm Design and Problem-Solving
Validation
What is Validation?
An automatic check carried out by a computer as data is entered, to make sure the data satisfies stated rules such as being within a range, of a required length, of an expected data type, present at all, in a required format, or consistent with a calculated check digit; validation establishes that data is reasonable, not that it is correct.
This definition is part of the Algorithm Design and Problem-Solving chapter in Cambridge O Level Computer Science.
Validation in context
Topic 7 is about the work that happens before and around writing code. You analyse a problem (identify it, strip away what does not matter, break it into parts, and name the inputs, processes, outputs and storage), you design a solution (structure diagram, flowchart, pseudocode), you code it, and you test it with data you chose on purpose. Along the way you use a small fixed set of standard methods — linear search, bubble sort, totalling, counting, maximum, minimum, average — you protect the input with validation and verification, and you prove behaviour with trace tables and with normal, abnormal, extreme and boundary test data. Nothing in this topic requires you to be fluent in a programming language; it requires you to be exact.
Validation is an automatic check, carried out by the computer as data is entered, that the data satisfies stated rules. It is needed because a program that accepts anything a user types will eventually produce nonsense — a negative age, an empty name, a mark of 5000. What validation cannot do is establish that the data is true. It only establishes that the data is possible.
Common mistakes with Validation
- M15. “Validation proves the data is correct.” Correct Validation proves the data obeys the stated rules. A pupil aged 15 who types 13 passes every check you could write.
Questions students ask about Validation
How do I know whether to use FOR, WHILE or REPEAT?
Ask two questions. Is the number of repetitions known before the loop starts? If yes, use FOR. If no: must the body run at least once? If yes, use REPEAT … UNTIL (this is why validation loops are almost always REPEAT); if it might need to run zero times, use WHILE … ENDWHILE.

