Library Computer Science 0478 Validation & Verification
O Level · Computer Science 0478

Validation & Verification

Revise Validation & Verification for Computer Science 0478 (O Level) — revision notes and instant AI marking. Free to start.

📖 Revision notes · preview
  Cambridge (CIE) IGCSE Computer Science

Validation & Verification

Big idea: computers can automatically check if data is sensible (validation), but only a human — or a clever double-check trick — can confirm data is actually correct (verification). One catches nonsense; the other catches typos.

Summary — What This Chapter Covers

  • Validation — an automated check by the computer that input data is sensible and meets rules. Six types: range, length, type, presence, format, check digit.
  • Verification — checking that data entered matches what was intended. Two methods: double entry checking, visual checks.
  • Validation ≠ Verification — validation can be fooled by "correct but wrong" data (e.g. a valid but mistyped age); verification catches that, but can't catch nonsense data on its own.
  • Suitable test data — four categories used to properly test a program: normal, abnormal, extreme, boundary.
  • Trace tables — a manual, step-by-step way of tracking variable values as an algorithm runs, used to find logic errors or understand what a program does.

1. Validation

Validation is an automated process — meaning the computer does it, not a human — where the program checks whether a piece of input data is sensible and follows the rules the program has set for that field. Think of it like a bouncer at a club door: the bouncer doesn't know if you're really the person on your ID, but they will stop you if your ID is obviously fake, expired, or the wrong shape. That's exactly what validation does — it can't tell if data is true, only whether it's plausible.

For example, if a field asks for someone's age and they type "elephant", validation will catch that instantly, because "elephant" fails a type check (it isn't a number). But if that same person types "25" when their real age is actually 52, validation will happily accept it — 25 is a perfectly sensible, valid age. Validation has no idea it's the wrong number. That's the key limitation to remember for exams.

Six types of validation you must know: Range check, Length check, Type check, Presence check, Format check, Check digit. A single field can use more than one at once — e.g. a password field might need a length check and a presence check and a type check.

Range Check

A range check makes sure a numeric value falls between an acceptable minimum and maximum. It's the classic "is this number too high or too low" test.

OUTPUT "Enter a number between 0 and 100" REPEAT INPUT Number IF Number < 0 OR Number > 100 THEN OUTPUT "Number is not between 0 and 100, please try again" ENDIF UNTIL Number >= 0 AND Number <= 100

In Python, the same idea for an age between 0 and 110 (inclusive) uses a while loop that keeps re-asking until the condition is satisfied:

age = int(input("Enter your age")) while age < 0 or age > 110: age = int(input("Enter your age, ensure it is between 0-110"))
Practice Question

A programmer writes a range check that only accepts a score between 0 and 50 inclusive. A student enters -3, then 51, then 25. Which of these values would be accepted, and why?

Length Check

A length check counts the number of characters in a string and rejects it if it doesn't match a required length (or minimum length). This is different from a range check — a range check works on numbers as values, a length check works on strings as character counts.

OUTPUT "Please enter your 4 digit bank PIN number" REPEAT INPUT Pin IF LENGTH(Pin) <> 4 THEN OUTPUT "Your pin number must be four characters in length, please try again" ENDIF UNTIL LENGTH(Pin) = 4
password_length = len(password) while password_length < 8: password = input("Enter a password which is 8 or more characters")
Practice Question

Why can't a length check on its own guarantee that a password is secure?

Type Check

A type check confirms the data entered is of the correct data type — for example, that a number field really contains a number rather than text.

OUTPUT "Enter an integer number" REPEAT INPUT Number IF Number <> DIV(Number, 1) THEN OUTPUT "Not a whole number, please try again" ENDIF UNTIL Number = DIV(Number , 1)
age = input("Enter your age") while age.isdigit() == False: print("enter a number") age = input("Enter your age as a number")
Watch the trick here: DIV(Number, 1) is used in pseudocode to test if a number is a whole number — if dividing by 1 (integer division) gives back the same value, there's no decimal part.

Presence Check

A presence check simply confirms that something was typed into a field at all — it stops blank/empty submissions.

OUTPUT "Enter your username" REPEAT INPUT Username IF Username = "" THEN OUTPUT "No username entered, please try again" ENDIF UNTIL Username <> ""
name = input("Enter your name") while name == "": name = input("You must enter your name here")

Format Check

A format check ensures data follows a specific pattern — this is the most complex of the six because it usually involves pattern matching and string handling (checking individual characters one at a time). A classic example is an ID number that must follow the pattern "XX9999" — two uppercase letters followed by four digits.

// Check the first character is an uppercase letter ValidChars ← "ABCDEFGHIJKLMNOPQRSTUVWXYZ" FirstChar ← SUBSTRING(IDNumber, 1, 1) ValidChar ← False Index ← 1 WHILE Index <= LENGTH(ValidChars) AND ValidChar = False DO IF FirstChar = SUBSTRING(ValidChars, Index, 1) THEN ValidChar ← True ENDIF Index ← Index + 1 ENDWHILE IF ValidChar = False THEN OUTPUT "First character is not a valid uppercase alphabetical character" ENDIF // The digits (positions 3-6) are cast to an integer and range-checked 0-9999 Digits ← INT(SUBSTRING(IDNumber, 3, 4)) IF Digits < 0 OR Digits > 9999 THEN OUTPUT "Digits invalid. Enter four valid digits in the range 0000-9999" ENDIF

Notice the pattern: the algorithm loops through every letter in a list of "valid characters", compares the input character to each one, and sets a flag (ValidChar) to True the moment it finds a match. If it finishes the whole loop without finding a match, the character must be invalid. This "search through a list of valid options" technique comes up constantly in format checks.

A simpler, real-world format check is validating an email address contains both an "@" and a "." — a very rough but common check:

email = input("Enter your email address") while "@" not in email or "." not in email: email = input("Please enter a valid email address")
Practice Question

Would the email format check above accept the input "@@..@"? Is that a problem?

Check Digit

A check digit is a numerical value calculated from the rest of a code (using an algorithm) and then attached onto the end of that code — commonly seen on barcodes and ISBNs (International Standard Book Numbers). When the code is scanned or entered, the computer re-runs the same algorithm on the other digits and compares the result to the check digit. If they don't match, the code was entered or scanned incorrectly.

Think of a check digit like a mathematical "seal" on a code — if even one digit gets mistyped or a barcode gets smudged and misread, the recalculated check digit won't match the one attached, and the error is caught instantly.

2. Verification

Verification is the process of checking that data entered into a system is accurate — that it genuinely matches what the person intended to type. This is a completely different job to validation. Validation asks "is this data sensible?" Verification asks "is this data correct?" A mistake here — like registering an account and mistyping your password — can be really frustrating, because you might get locked out of your own account without realising you typed it wrong in the first place.

Two verification methods you must know: Double entry checking and Visual checks.

Double Entry Checking

This involves asking the user to type the same piece of data twice, into two separate input boxes, and then the computer compares the two entries. If they match, the data is accepted. If they don't match, an error message appears and the user tries again. You'll recognise this instantly from every "confirm your password" box you've ever filled in when signing up for a website.

REPEAT OUTPUT "Enter your password" INPUT Password OUTPUT "Please confirm your password" INPUT ConfirmPassword IF Password <> ConfirmPassword THEN OUTPUT "Passwords do not match, please try again" ENDIF UNTIL Password = ConfirmPassword

Visual Checks

This involves the user visually looking at the data displayed back on the screen and confirming (usually via a "y/n" prompt or a popup) that it's correct before the program proceeds. If the data is wrong, the user re-enters it.

REPEAT OUTPUT "Enter your name" INPUT Name OUTPUT "Your name is: ", Name, ". Is this correct? (y/n)" INPUT Answer UNTIL Answer = "y"
Common exam trap: students often confuse validation and verification, or think one "does the job of" the other. They don't overlap! A value can pass validation (it's sensible) but fail verification (it's not what was intended) — and vice versa is impossible, because verification just compares two pieces of data; it says nothing about whether that data is sensible on its own.
Practice Question

Describe the purpose of validation and verification checks during data entry. Include an example of each. (4 marks)

3. Suitable Test Data

Once a program has validation rules in place, you need to actually test that those rules work correctly — and for that, you can't just throw in random numbers. Good testers deliberately choose data from four categories to make sure every part of the logic is exercised, including the edges where bugs love to hide.

Consider this simple Python program used as the running example for all four categories below — it checks whether someone's age (12–18 inclusive) is accepted:

age = int(input("How old are you? ")) if age >= 12 and age <= 18: print("Welcome! Your age is accepted.") else: print("Sorry. Your age is not accepted.")

Normal Data

Data that should be accepted by the program under normal, everyday circumstances — a value clearly within the expected range. Example: entering age 16.

Abnormal Data

Data that is the wrong type entirely and should be rejected — this tests that your validation catches nonsense input, not just out-of-range numbers. Example: entering "F" into the age field.

Extreme Data

The maximum and minimum values of normal data that should still be accepted by the system — these sit right at the very edge of the acceptable range. Example: entering age 12 or 18 (both are the outer limits, but both should still be welcomed).

Boundary Data

Data that sits one step just outside the accepted range on either side — the very next values that should be rejected. This is subtly different from extreme data: extreme data tests the last acceptable value, while boundary data tests the first unacceptable value right next to it. Example: entering age 11 or 19 (one below/above the accepted 12–18 range).

Easy way to remember the difference: Extreme = the edge of the "yes" zone. Boundary = the edge of the "no" zone, right next door to extreme data.

Putting It Together

Type of TestInputExpected Output
Normal14Accepted
Normal16Accepted
Extreme12Accepted
Extreme18Accepted
AbnormalHRejected
Abnormal@Rejected
Boundary11Rejected
Boundary19Rejected
Practice Question

A programmer has written an algorithm to check that prices are less than $10.00. These values are used as test data: 10.00, 9.99, ten. State why each value was chosen as test data. (3 marks)

Practice Question

A system accepts test scores between 0 and 100 inclusive. Suggest one piece of boundary test data and explain what the expected result should be.

4. Trace Tables

A trace table is a manual method of testing an algorithm — flowchart, pseudocode, or actual program code — by tracking exactly what happens to every variable, step by step, as the algorithm runs. Think of it as "playing computer" with a pen and paper: you follow the instructions exactly the way a computer would, writing down the value of every variable each time it changes, and noting any output produced.

Trace tables are useful for two main purposes:

  • Discovering the purpose of an algorithm — by watching the outputs and intermediate steps unfold, you can work out what an unfamiliar piece of code is actually trying to achieve.
  • Recording the state of the algorithm at each step or iteration — this is exactly how you catch logic errors, because a mistake in the algorithm will show up as an unexpected value appearing in the table.

Worked Walkthrough: Finding the Highest Number

Here's a flowchart algorithm that finds the highest of ten user-entered numbers. The first number entered automatically becomes the "highest so far". Then, for each of the next nine numbers, if the new number beats the current highest, it replaces it. Let's trace it with the test data: 4, 3, 7, 1, 8, 3, 6, 9, 12, 10.

CountHighestNumberOutput
1Enter ten numbers
4Enter your first number
23Enter your next number
377
41
588
63
76
899
91212
101012 is your highest number

Notice the pattern: Highest only gets a new value written in the table when a number actually beats the current highest (3 doesn't beat 4, so Highest stays blank in that row — it hasn't changed). This is the golden rule of trace tables: only write a value in a column when it actually changes. This keeps the table clean and makes it obvious exactly which step caused which update.

Exam tip: examiners specifically check that you leave a cell blank when a variable hasn't changed on that row — filling in every cell with a repeated value is a common way students lose marks, because it suggests you don't understand that the value only actually updates on certain steps.
Practice Question

A flowchart algorithm inputs a Value. If Value = -1, the program ends. Otherwise, if Value is between 50 and 100 inclusive, it calculates Diff1 = 100 - Value and Diff2 = Value - 50. If either Diff is less than 1, it outputs "Accept: Extreme"; otherwise it outputs "Accept: Normal". If Value is not between 50–100, it outputs "Reject: Abnormal".

Complete a trace table row for the input 75.

Practice Question

Using the same algorithm as above, what would happen for the input 150, and why?

What to Memorise

Validation
Automated computer check that input data is sensible and meets program rules. Can't tell if data is true, only if it's plausible.
Verification
Checking that data entered matches what was intended — catches mistakes validation can't see.
Range check
Numeric value must fall within a set minimum/maximum.
Length check
String must be a specific number of characters (or meet a minimum).
Type check
Data must be of the correct data type (e.g. integer, not text).
Presence check
Field must not be left blank.
Format check
Data must follow a defined pattern, using pattern matching/string handling.
Check digit
Number calculated from a code (e.g. barcode, ISBN) and attached to detect entry/scanning errors.
Double entry checking
Data typed twice into separate boxes; entries compared to confirm they match.
Visual check
User visually confirms displayed data is correct before proceeding.
Normal data
Sensible data that should be accepted by the program.
Abnormal data
Wrong data type; should be rejected.
Extreme data
The maximum/minimum values of normal data that should still be accepted.
Boundary data
Values one step beyond extreme data on either side; should be rejected.
Trace table
Manual step-by-step record of variable values as an algorithm runs, used to find logic errors.

Concepts Checklist

Exam Tips & Common Mistakes

Mistake: confusing validation with verification. Remember — validation is about whether data is sensible; verification is about whether data is accurate to what was intended. Never describe a range check as "verification".
Mark scheme trap: when asked to "give an example" of validation or verification, examiners want a named type (e.g. "range check", "double entry check") — not just a vague description like "checking the data is right".
Trace table tip: only write a new value in a cell when that variable's value actually changes on that row. Leaving previous cells blank (rather than repeating the value) is what examiners expect and mark for.
Test data tip: when a question gives you a range like "12 to 18 inclusive", extreme data is 12 and 18 themselves (still accepted); boundary data is 11 and 19 (the very next values, which should be rejected). Mixing these two up is one of the most common errors in this topic.
Common question pattern: "State why each value was chosen as test data" — always explain both which category the value belongs to (normal/abnormal/extreme/boundary) and what the expected outcome should be (accepted/rejected). Half marks are often lost by only stating one of these two things.
Remember: a check digit doesn't prevent errors — it detects them after the fact, by comparing a recalculated value against the one stored in the code.
Validation & Verification — Revision Guide · Based on Cambridge (CIE) IGCSE Computer Science · Built for offline study
🔓 Read the full Validation & Verification note — free You're seeing the preview · free account, no card needed
Also in the full note
  • Exam Tips & Common Mistakes
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise Validation & Verification with Computer Science 0478 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full Validation & Verification notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics