Teachers' Portal  /  IGCSE Computer Science 0478  /  Algorithm design and problem-solving  /  Validation and verification checks
Lesson pack · IGCSE Computer Science 0478 · 7 (5-6) · IGCSE

Validation and verification checks

Sensible is not the same as correct. Programs must not accept nonsense such as an age of 250 or an empty name.

Student lesson Lab, full screen
At a glance

The shape of the lesson

Topic
Algorithm design and problem-solving
Syllabus reference
Cambridge IGCSE Computer Science 0478, 7 (5-6)
Level
IGCSE
Duration
45 minutes, lab-led; stretches to a 60 minute block (see the contingency notes)
Position in topic
Lesson 5 of 9 in Algorithm design and problem-solving; follows Standard methods: totalling, counting, maximum, minimum and average; leads into Normal, abnormal, extreme and boundary test data
Central model
Fig. 1: validation asks whether data is allowed; verification asks whether it was entered as intended
Cooperative structure
Assessment
Stage 1 check and the exam-style plenary from the student lesson, plus the worksheet as the exit task
Learning objectives

By the end of the lesson, learners can

Section by section
  • Six validation checks: Type different values into the validation tab of the lab and see which check accepts or rejects each one.
  • Check digits: A check digit is an extra digit worked out from the other digits and added to the end.
  • Verification: entered as intended: Data can pass every validation check and still be wrong: a date of birth of 12/03/2009 typed instead of 21/03/2009 is perfectly sensible.
Key points to leave on the board
  • Validation (automatic): range, length, type, presence, format, check digit.
  • Verification: visual check, double entry check.
  • Describe a check: say what it tests and give an example from the question's context.
  • Write a check: input, test the rule, error message, input again until valid.
The core visual model

One picture every idea returns to

Validation is an automatic check by the computer that input data is sensible and allowed before it is accepted: range, length, type, presence, format and check digit checks. Verification checks that data has been entered accurately, matching the original: a visual check or a double entry check. Validation cannot prove data is correct, only that it is reasonable.

Data is entered Validation (automatic) Is the data sensible and allowed? range, length, type, presence, format, check digit Verification Was it copied in exactly as intended? visual check, double entry check
Fig. 1: validation asks whether data is allowed; verification asks whether it was entered as intended
Lesson sequence

Forty-five minutes, phase by phase

TimePhaseWhat happens in the roomGrouping
0 to 5 minHook: predictOpen with the question in the title, Sensible is not the same as correct.. Programs must not accept nonsense such as an age of 250 or an empty name. Put the figure on the board: it is the one picture every idea in the lesson returns to.Whole class, then pairs
5 to 13 minTeach and check: Six validation checksType different values into the validation tab of the lab and see which check accepts or rejects each one. Project tab 3 of the lab (Validation checks) and let a student drive it while the class predicts.Whole class, then pairs
13 to 21 minTeach and check: Check digitsA check digit is an extra digit worked out from the other digits and added to the end. Model the worked example ISBN-13 check digit on the board, one line at a time. Your turn: Calculate the ISBN-13 check digit for 978014103614.Pairs
21 to 30 minTeach and check: Verification: entered as intendedData can pass every validation check and still be wrong: a date of birth of 12/03/2009 typed instead of 21/03/2009 is perfectly sensible.Cooperative Concept Mapping
30 to 36 minCheckThe four Stage 1 questions from the student lesson, answered on mini whiteboards or by show of fingers. Re-teach the one most get wrong.Individual, then whole class
36 to 43 minPlenaryThe exam-style questions from Stage 2, one at a time: thirty seconds alone, then a random call. The feedback lines in the key give the examiner's wording.Individual, random call
43 to 45 minExit and homeworkSet the worksheet below (6 questions, 17 marks). Learners self-assess against the objectives before they leave.Individual
Timing and contingency

Protect the parts that carry the learning

The sequence carries about fifty minutes of material, so the lab is driven by one student while the class predicts rather than explored freely. Times are a guide.

Protected: the check at 30 minutes. It is the only individual read on whether the key idea landed, and it is not cut.

Cut first if the build overruns: the last check in Verification: entered as intended, never the check or the plenary.

In a 60 minute block: run worksheet questions 1 to 3 in class as a Rally Coach set and model both the hardest worked example and its check live.

Running the cooperative task

Cooperative Concept Mapping

Teams receive the key terms on cards and arrange them on a large sheet, drawing and labelling the links. Compare maps between teams before showing the model map.

The full structure, with its variations and the other twelve, is on the cooperative-learning page.

Examiner traps to pre-empt

What to head off, and how

Trap learners fall intoTeaching move that pre-empts it
A range check is about the value (13 is too big); a length check is about the number of characters ("abc" is too short).Name the check that matches the rule in the question.
A check digit is a validation check (it is calculated automatically), even though it catches typing mistakes.It cannot tell you whether the number is the right book, only that the digits are consistent.
Validation and verification are not interchangeable.Validation: is the data reasonable? Verification: is it the same as the original? Neither guarantees the data is true.
Worksheet

Validation and verification checks: worksheet

6 questions, 17 marks. Written in the style of the papers; no past paper question is reproduced.

NameClassDate
Q1 · explain[2 marks]

Explain why validation checks are needed on input data.

Q2 · apply[4 marks]

A sign-up form asks for a username (6 to 12 characters), an age (13 to 99) and an email address. Identify a suitable validation check for each, and one more check that applies to all three fields.

Q3 · calculate[3 marks]

An ISBN-13 is entered as 9781234567896. Use the check digit method (weights 1 and 3, sum MOD 10, subtract from 10) to show that it has been entered incorrectly.

Q4 · write[4 marks]

Write pseudocode to input a percentage and use a range check so that only values from 0 to 100 inclusive are accepted. An error message must be output for each invalid value.

Q5 · explain[2 marks]

Describe how a double entry check works.

Q6 · analysis[2 marks]

A student's date of birth is entered as 14/07/2010 instead of 17/04/2010. Explain why a format check does not detect this error, and name a check that could.

Answer key and marking notes
Q1 · 2 marks
  • To make sure only sensible / reasonable data that meets the rules is accepted.
  • So that impossible or unreasonable data is rejected before it is processed or stored (reducing errors in the output).
Q2 · 4 marks
  • Username: length check (6 to 12 characters).
  • Age: range check (13 to 99) or type check (integer).
  • Email: format check (contains @ and a full stop in the right places).
  • All three: presence check (none may be left empty).
Q3 · 3 marks
  • Weighted sum of the first 12 digits: 9 + 21 + 8 + 3 + 2 + 9 + 4 + 15 + 6 + 21 + 8 + 27 = 133.
  • 133 MOD 10 = 3; 10 − 3 = 7.
  • The calculated check digit 7 does not match the entered digit 6, so there is an error.
Q4 · 4 marks
  • Prompt and INPUT Percentage.
  • Loop (WHILE or REPEAT) while Percentage < 0 OR Percentage > 100.
  • Output an error message inside the loop.
  • INPUT Percentage again inside the loop, so the loop ends when the value is valid.
Q5 · 2 marks
  • The data is entered twice (e.g. a new password typed twice).
  • The computer compares the two entries; if they do not match, the data is rejected and must be entered again.
Q6 · 2 marks
  • The wrong date still has the correct DD/MM/YYYY format (and is a possible date), so it passes the format check.
  • A verification check: a visual check against the original document (or double entry).
Quiz

6 multiple-choice questions on this lesson

From the topic question bank. Assign them in the app for a marked score in your gradebook, or run the topic as a class game.

Q11 mark

A mobile phone number must be entered as exactly 11 characters. Which validation check tests this rule?

  • Alength check
  • Brange check
  • Cpresence check
  • Dtype check
Q21 mark

Which of these is a verification check?

  • AA clerk compares the postcode on screen with the paper form
  • BThe program rejects a postcode that does not contain a space
  • CThe program rejects a form with the postcode field left empty
  • DThe program rejects a postcode longer than 8 characters
Q31 mark

The ISBN-13 check digit is found by multiplying the first 12 digits alternately by 1 and 3, adding the products, finding the sum MOD 10 and subtracting the result from 10 (a result of 10 gives 0). What is the check digit for 978030640615?

  • A7
  • B3
  • C1
  • D9
Q41 mark

Which type of validation check does this pseudocode carry out?

REPEAT
    OUTPUT "How many items? (1 to 20)"
    INPUT Quantity
UNTIL Quantity >= 1 AND Quantity <= 20

  • Arange check
  • Blength check
  • Cpresence check
  • Ddouble entry check
Q51 mark

A product number is six digits followed by a seventh digit, a check digit. Which input error would the check digit detect that a format check would not?

  • Atwo neighbouring digits typed the wrong way round
  • Ba letter typed in place of one of the digits
  • Cthe product number field left completely empty
  • Dthe correct number of a different product
Q61 mark

This range check is run and the user types 0, then 7, then 6, then 2. How many times is the error message output, and which value of Tickets is accepted?

REPEAT
    OUTPUT "Enter the number of tickets (1 to 6)"
    INPUT Tickets
    IF Tickets < 1 OR Tickets > 6
      THEN
        OUTPUT "Error: enter a number from 1 to 6"
    ENDIF
UNTIL Tickets >= 1 AND Tickets <= 6

  • A2 error messages; 6 is accepted
  • B2 error messages; 2 is accepted
  • C3 error messages; 2 is accepted
  • D1 error message; 7 is accepted
Quiz key
Q1: A

A length check tests the number of characters, here exactly 11. A range check tests that a value lies between two limits, which is not how a phone number is checked. A presence check only tests that something has been entered, and a type check tests the data type, so neither would reject a 10-character number.

Q2: A

Comparing the entered data with the original document is a visual check, a form of verification. Rejecting a postcode without a space is a format check, an empty field is caught by a presence check and more than 8 characters by a length check: these are all automatic validation checks.

Q3: A

Weighted sum: 9 + 21 + 8 + 0 + 3 + 0 + 6 + 12 + 0 + 18 + 1 + 15 = 93. 93 MOD 10 = 3 and 10 - 3 = 7. Giving 3 forgets to subtract from 10. Adding the digits without the weights gives 49, so 1 (after subtracting) or 9 (without subtracting) both come from leaving out the weights.

Q4: A

Testing that Quantity lies between 1 and 20 is a range check. A length check would use LENGTH to count characters, a presence check would test for an empty input, and a double entry check (verification) would compare two inputs of the same data.

Q5: A

Swapping two digits keeps the format (seven digits) so a format check accepts it, but the recalculated check digit no longer matches. A letter instead of a digit breaks the format, so the format check already catches it. An empty field is caught by a presence check (and fails the format). A valid number for the wrong product passes both checks, because it is consistent; only verification against the source could catch it.

Q6: A

0 is below 1 and 7 is above 6, so each gives an error message. 6 is within 1 to 6 (the limit is included), so the UNTIL condition is true and the loop ends with 6 accepted; the 2 is never read. Accepting 2 or counting 3 errors treats 6 as invalid. 7 is outside the range, so it cannot be accepted.

Lab and demo

What to project

The student lesson embeds these tabs. Open them full screen on the projector; every slider has a drag handle on the stage.

Slides

Slides for this lesson

A projectable deck for every pack is on the way. Until then, present the student lesson full screen: its sections, figure and lab tabs follow the same order as the plan above.

Also for this topic

Everything else you can use

Original work by the TheLucidSTEM team. The worksheet items are written in the style of the papers; no past paper question is reproduced.
Previous lessonStandard methods: totalling, counting, maximum, minimum and average