Single lesson · Written for AQA GCSE Computer Science (8525)

Validation routines – AQA GCSE Computer Science lesson (8525)

Pupils learn to write validation routines in the class's language that check presence, length and range.

Also in a bundle Cyber Security and Robust Programs – AQA GCSE Computer Science lessons (8525) 14 lessons for £39 · save 30% on buying separately

Lesson 8 of 14 in unit 11.1 Cyber Security and Robust Programs, taught in Year 11, Autumn 1. It answers one big question: How can a program refuse input that does not make sense?

By the end, pupils can write validation routines in the class's language that check presence, length and range.

The Build (the main task)
Write a program for Kickstand's order form that: inputs a shoe size; keeps asking for the size until a whole number from 3 to 13 is entered; then inputs a discount code; outputs Code rejected if the code is empty or shorter than 6 characters, otherwise outputs Code accepted. You should use indentation and meaningful identifiers. (7 marks)
Support version
Part-filled code with the first WHILE loop written.
Challenge
Rewrite the size check as a function validSize that takes a size as a parameter and returns True if it is from 3 to 13, otherwise False. Use it in a loop that keeps asking until a valid size is entered. (6 marks) Kickstand customers choose a username. Write a program that keeps asking for a username until it is not empty and is 5 to 12 characters long, then outputs Welcome followed by the username. (7 marks)
Real-world link
Kickstand's order form checks shoe sizes and discount codes.
Key words
Validation, Range check and Acceptable, each with a definition, an icon and a common mix-up on the key vocabulary slide.
Misconceptions it tackles
“Validation checks the data is correct”; “Checking once with IF is enough”.
AQA 8525 specification
3.2.11 (robust and secure programming: validation, authentication, testing, test data, errors).

Every lesson follows the same Code & Commerce structure: a Bell Task recall starter, key vocabulary with definitions and icons, short teaching chunks with a check before pupils move on, The Build (one main task), challenge questions that get harder, and an exit question. Answers reveal one at a time on the slides, and everything is editable PowerPoint and Word.

Pupils need computers for the main task.

Also sold in the Cyber Security and Robust Programs unit bundle, which includes the medium term plan, and in the full-year and complete-course bundles.

Choose your school's Paper 1 language when you buy: C#, Python or VB.NET. You get that language's files: every program, code example, worked answer and programming task is written in it, and lessons with no code are the same in all three. Algorithms are also shown in AQA pseudo-code, as in the exam.

An independent resource written for AQA GCSE Computer Science (8525). It is not endorsed by AQA.

What's included

  • Slide deck (PowerPoint)
  • Lesson plan (Word)
  • Worksheet (Word)
  • Support worksheet with scaffolds (Word)
  • Single-teacher licence: use and adapt it with your own classes
  • Your choice of Paper 1 language: C#, Python or VB.NET

More for GCSE Computer Science (AQA)

See all

Written for the specifications named. Not endorsed by or affiliated with any exam board.