Input validation checks that user input is sensible, complete, and within acceptable ranges before processing. It prevents errors and protects the program from bad data.
REPEAT age ← INT(USERINPUT) UNTIL age >= 0 AND age <= 120 OUTPUT 'Valid age: ' + STR(age)
Types of validation:Range check · Type check · Presence check · Length check · Format check
Authentication
Verifying User Identity
PASSWORD CHECK
stored ← 'secret123' attempts ← 0 REPEAT pw ← USERINPUT attempts ← attempts + 1 UNTIL pw = stored OR attempts = 3 IF pw = stored THEN OUTPUT 'Access granted' ELSE OUTPUT 'Locked out' ENDIF
AUTHENTICATION METHODS
Username + password
Two-factor authentication (2FA)
Biometrics (fingerprint, face ID)
Security questions
Testing
Making Programs Reliable
Test Type
Purpose
Example (age 0–120)
Normal
Typical valid values
25, 60
Boundary
Edges of allowed range
0, 1, 119, 120
Erroneous
Values that should be rejected
-1, 121, 'abc'
Exam Practice
Have a go at this question
AQA-style question
Write pseudocode to ask a user for a score between 0 and 100 and repeat until a valid score is entered. Then output 'Valid score' when accepted.
3 marks
REPEAT score ← INT(USERINPUT) UNTIL score >= 0 AND score <= 100 OUTPUT 'Valid score'
Key Takeaways
What to Remember
Input validation — check data is sensible before using it (range, type, presence)
Authentication — verify who the user is before giving access
Test with normal, boundary, and erroneous data
REPEAT UNTIL is the standard pattern for input validation loops