Skip to content
SPM Tuition
Computer Science · Algorithm reasoning and test design

Validation versus verification in a classroom program

You keep swapping the words validation and verification and both feel like the same idea.

Validation checks that data is reasonable and follows a rule. Verification checks that the data entered is the data the user really meant. Both protect a program, but they catch different kinds of error.

This lesson belongs to algorithm reasoning and test design. It builds on the idea of invalid data from choosing normal, boundary and invalid test data.

What is the classroom program?

A class uses a small program to register students for a science fair. It asks for the student’s form number, which must be 1 to 5, and then for a class code chosen by the student.

The program asks for the form number once, and asks for the class code twice. Those two behaviours show the two ideas.

Which step is validation?

The form number check is validation. The program tests the value against a rule:

INPUT form
WHILE form < 1 OR form > 5
  OUTPUT "Enter a form from 1 to 5"
  INPUT form
END WHILE

The program does not know the true form. It only knows that 9 or 0 is impossible and refuses it. A value of 4 from a Form 3 student would still be accepted.

Which step is verification?

The class code entered twice is verification. The program compares the two entries:

INPUT code1
INPUT code2
IF code1 <> code2 THEN
  OUTPUT "Codes do not match"
END IF

Here the program cannot judge whether the code is sensible. It only checks that the student typed the same thing both times, which reduces the chance of a slip.

How do you keep them apart?

Ask what each check is protecting.

Question Validation Verification
What does it check? Data follows a rule Data matches the intended value
Examples Range, length, type, presence Entering twice, reading back
What can it miss? A sensible but wrong value A value that breaks the rule in both entries

A common mistake is to call double entry “validation because it checks the input”. The word to watch is intended. Double entry checks accuracy against what the user meant, so it is verification.

Check yourself

A school library program asks for a book’s ISBN. It rejects any entry that is not exactly 13 digits, then shows the typed number on screen and asks the student to confirm it. Name the validation step and the verification step.

Answer

The rule “exactly 13 digits” is validation, specifically a length check together with a type check for digits.

Showing the number back and asking for confirmation is verification. It lets the student notice a wrong digit that still satisfied the 13-digit rule.

What to study next

Move on to the integrated algorithm reasoning and test design practice, or review your own slips with the mistake log and paper-error review.

If you would like a teacher to test your wording on exam-style answers, see online one-to-one Computer Science tuition.

Common questions

What is the simplest way to tell validation from verification?

Validation asks whether the data is sensible and allowed, such as an age between 13 and 18. Verification asks whether the data was entered or copied correctly, such as typing a password twice. One checks the rule, the other checks accuracy.

Can data pass validation and still be wrong?

Yes. A student typing 17 instead of 16 passes a range check of 13 to 18, yet the value is wrong. Validation cannot know the true answer, which is why verification steps such as re-entry exist.

Is a range check validation or verification?

It is validation. It tests the value against a rule, such as a minimum and maximum. So are a presence check, a length check and a type check.

Do the two terms ever appear in the same program?

Yes, in the same form. A registration form may validate that an email contains an at sign, then verify it by asking the user to type it a second time.

If these two terms still blur when you write an exam answer, a one-to-one Computer Science teacher can give you fresh examples until the difference is automatic.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.