Validation and authentication
Users make mistakes and some try to break things. Validation checks data is sensible; authentication checks who someone is.
Validation checks
| Check | What it tests | Example |
|---|---|---|
| Presence check | Something has been entered | Surname is not left blank |
| Length check | The data has a suitable number of characters | Password at least 8 characters |
| Range check | A value is between limits | Age from 11 to 18 |
| Pattern check | The data matches a format | An email contains @ |
Validation with a loop
age = int(input("Age: "))
while age < 11 or age > 18:
print("Out of range")
age = int(input("Age: "))
print("Accepted")
Authentication
The usual method is an ID and password.
A lookup checks the entered details against stored records, for example a list or a file of users.
users = [["amir", "Cat#42"], ["beth", "Sun!77"]]
uid = input("ID: ")
pw = input("Password: ")
found = False
for user in users:
if user[0] == uid and user[1] == pw:
found = True
print(found)
Which validation checks suit a UK mobile number entered as 11 digits starting 07?
- It must be entered: presence check.
- It must be 11 characters: length check.
- It must start with 07 and contain only digits: pattern check.
Answer: Presence, length and pattern checks
Presence, length, range and pattern checks make sure data is sensible. A while loop re-asks until valid. Authentication confirms identity, usually by looking up an ID and password.
- Validation
- Checking that input data is sensible and allowed before it is used.
- Authentication
- Confirming that a user is who they claim to be, for example with an ID and password.
All GCSE and International GCSE Computer Science key terms and definitions →
Try two quick questions
See if it has sunk in. Answers are marked straight away.
2 more questions
Try each one, then tap to check.
Which check makes sure an age is between 11 and 18?
- Presence check
- Length check
- Pattern check
- Range check
Show the answer
Answer: Range check
A range check tests limits.
A username must be no more than 15 characters. Which check is this?
- Range check
- Length check
- Presence check
- Lookup
Show the answer
Answer: Length check
Counting characters: length check.
Check you have got it
Answer 7 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.
- Pearson Edexcel GCSE Computer Science (1CP2) specification, topic 6.4.3, 6.4.4
- Pearson Edexcel International GCSE Computer Science (4CP0) specification, topic 2.4.2, 5.2.1
Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.
What do exam command words like explain and evaluate mean? →