Unit 11.4A · Term 4

Validation & Verification

Before data is processed, we must ensure it is both reasonable (validation) and correct (verification). These are two different but complementary processes that prevent errors from entering a system.

Learning Objectives

  • 11.1.2.5 Explain the difference between verification and validation

Lesson Presentation

11.4A-validation-verification.pdf · Slides for classroom use

Conceptual Anchor

The Airport Security Analogy

Validation is like the X-ray scanner — it checks whether your bag contains allowed items (reasonable data), but it can't tell if it's your bag. Verification is like checking your passport photo against your face — it confirms the data is correct and belongs to you. Both are needed for security.

Rules & Theory

Key Definitions

Concept Definition Example
Validation An automated check to ensure data is reasonable, sensible, and within acceptable limits. Does NOT guarantee correctness. Age must be 0–150
Verification A manual or automated check to ensure data has been accurately transferred or entered. Confirms data matches the original. Re-type email to confirm

Key Distinction

Validation answers: "Is this data reasonable?"
Verification answers: "Is this data what was intended?"
Example: Entering age as 25 passes validation (0–150). But if the person is actually 52, it's valid but not verified.

Types of Validation Checks

Check Type What It Does Example
Range check Value falls within a specified range Mark must be 0–100
Type check Data is of the correct data type Age must be an integer
Length check Data has the correct number of characters Password at least 8 characters
Presence check A required field is not left empty Name field cannot be blank
Format check Data matches a specific pattern Date must be DD/MM/YYYY
Check digit Final digit is calculated from others to detect errors ISBN barcode, credit card (Luhn)
Lookup check Value must exist in a predefined list Country code must be in ISO list

Types of Verification

Method How It Works
Double entry User enters data twice — both entries must match (e.g., "Confirm password")
Screen/visual check User reviews entered data on screen before submission ("Is this correct? Y/N")
Parity check Extra bit added during transmission to detect errors
Checksum Mathematical value calculated from data; recalculated at destination to verify integrity

Worked Examples

1 Range Check — Mark Input (Pseudocode)

REPEAT OUTPUT "Enter mark (0-100): " INPUT mark IF mark < 0 OR mark > 100 THEN OUTPUT "Invalid! Must be 0-100." ENDIF UNTIL mark >= 0 AND mark <= 100 OUTPUT "Valid mark entered: ", mark

2 Length Check — Password (C++)

#include <iostream> #include <string> using namespace std; int main() { string password; do { cout << "Enter password (min 8 chars): "; cin >> password; if (password.length() < 8) cout << "Too short!" << endl; } while (password.length() < 8); cout << "Password accepted." << endl; return 0; }

3 Double Entry Verification (Pseudocode)

OUTPUT "Enter email: " INPUT email1 OUTPUT "Confirm email: " INPUT email2 IF email1 = email2 THEN OUTPUT "Email confirmed." ELSE OUTPUT "Emails do not match! Try again." ENDIF

Common Pitfalls

Confusing Validation with Verification

Students often mix them up. Remember: Validation = automated + reasonable. Verification = correctness + matches original. A value can be valid but incorrect (age = 25 when it should be 52).

Thinking Validation Guarantees Correctness

Validation only ensures data is reasonable. Entering 30 as your age passes a range check (0–150) even if you're actually 17. Validation cannot catch this.

Exam Tips

  • Always state the type of validation check (range, type, length, etc.)
  • For verification, specify the method (double entry, visual check)
  • A good answer explains why a specific check is appropriate for the data
  • Remember: validation is done by the computer, verification involves the user

Tasks

Remember

Define validation and verification. Give one example of each.

Understand

A registration form asks for a phone number. Which validation checks would be appropriate? Explain why each check is needed.

Apply

Write pseudocode for a program that asks the user to enter their age, validates it (0–120 range + integer type check), and then uses double-entry verification.

Analyze

A student enters "abc" into an age field. The program rejects it. Is this validation or verification? What type of check caught the error?

Self-Check Quiz

Q1: What is the main difference between validation and verification?

Validation checks if data is reasonable/sensible (automated); verification checks if data is correct/matches the original (often involves the user).

Q2: Which validation check ensures a password is at least 8 characters?

Length check

Q3: What verification method asks the user to type their email twice?

Double entry verification

Q4: Can valid data still be incorrect? Give an example.

Yes. Entering age as 25 passes range validation (0–150) but may be wrong if the actual age is 52.