Revise Computing
Revision notesQuestionsFor schools
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/Defensive Design

Validation checks

301.16 Defensive Design

Practise exam questions

Defensive Design — Note 2 of 5

Range length presence.

What you need to know

Validation checks ensure data meets specific criteria before processing. Common checks include range (within limits), length (correct size), and presence (not empty).

What to know

  • Range check: 0 <= age and age <= 120
  • Length check: len(password) >= 8
  • Presence check: name != ""
  • Type check: value.isdigit()
  • Use while loops to re-ask until valid

Code examples

Validation loop
python
age = -1
while age < 0 or age > 120:
    age = int(input("Enter age (0-120): "))
    if age < 0 or age > 120:
        print("Out of range, try again")
print("Age: " + str(age))
← Previous noteAnticipate misuse301.16 Defensive DesignNext note →Authentication301.16 Defensive Design

Back to Defensive Design

Specification notes for programming are in Paper 2.

Defensive Design

Note 2 of 5

  1. 1Anticipate misuse
  2. 2Validation checks
  3. 3Authentication
  4. 4Validation subprograms
  5. 5Error messaging
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Privacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).