Ad Banner Placeholder
Cambridge IGCSE Computer Science · 0478
Topic 7: Algorithm Design and Problem-Solving — Part 2
Validation, Verification & Test Data
Validation and verification
Validation is an automated check that data is reasonable and fits the rules before it is accepted. Common validation checks include:
| Check type | What it checks | Example |
|---|---|---|
| Range check | Value is within allowed limits | Month integer must be between 1 and 12 |
| Length check | Correct number of characters | Password must contain at least 8 characters |
| Type check | Data is the correct data type | An employee count field must accept integers only |
| Presence check | A required field is not left empty | Contact email address field cannot be left empty |
| Format check | Data matches a required pattern | Date must match the layout DD/MM/YYYY |
| Check digit | An extra digit confirms the rest of the data is correct | ISBN or barcode last digit verifies the code |
Verification checks that data matches the original source — it confirms accuracy, not just reasonableness. Two common methods are:
- Visual check — a person reads data from a source document and compares it with what was entered (e.g. checking a typed form against a paper application).
- Double entry check — critical data is entered twice into separate fields (e.g. a new PIN or email during registration); the system alerts the user if the two entries do not match.
Implementing checks in pseudocode:
A visual check is performed by a person and is not usually written as program code. A double-entry verification can be implemented as follows:
INPUT Password
INPUT ConfirmPassword
IF Password <> ConfirmPassword THEN
OUTPUT "Passwords do not match — please re-enter"
ELSE
OUTPUT "Password accepted"
ENDIF
A range validation (automated check that data is reasonable) looks like this:
INPUT Age
IF Age < 0 OR Age > 120 THEN
OUTPUT "Invalid age"
ELSE
OUTPUT "Age accepted"
ENDIFTest data types
When testing a program that accepts values in the range 1 to 100, use four types of test data:
| Test data type | Description | Example (range 1–100) |
|---|---|---|
| Normal | Typical valid data within the range | 25, 50, or 88 |
| Abnormal | Clearly invalid data that should be rejected | -12, 145, or "Excellent" |
| Extreme | The largest or smallest valid values in the range | 1 and 100 |
| Boundary | Values on the edge of the valid range — the valid extreme and the next invalid value | 0, 1, 100, and 101 |
0/15
Ad Banner Placeholder