Validation and authentication

Users make mistakes and some try to break things. Validation checks data is sensible; authentication checks who someone is.

Practise this lesson free (7 questions)

More tools

Validation checks

Validation checks data is sensible, not that it is correct: a valid age might still be the wrong age.
CheckWhat it testsExample
Presence checkSomething has been enteredSurname is not left blank
Length checkThe data has a suitable number of charactersPassword at least 8 characters
Range checkA value is between limitsAge from 11 to 18
Pattern checkThe data matches a formatAn email contains @

Validation with a loop

Keep asking until the data is valid:
age = int(input("Age: "))
while age < 11 or age > 18:
    print("Out of range")
    age = int(input("Age: "))
print("Accepted")

Authentication

Authentication confirms that users are who they say they are.
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)
Worked example

Which validation checks suit a UK mobile number entered as 11 digits starting 07?

  1. It must be entered: presence check.
  2. It must be 11 characters: length check.
  3. It must start with 07 and contain only digits: pattern check.

Answer: Presence, length and pattern checks

Key idea

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.

Key words
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 →

Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. Which check makes sure an age is between 11 and 18?

    1. Presence check
    2. Length check
    3. Pattern check
    4. Range check
    Show the answer

    Answer: Range check

    A range check tests limits.

  2. A username must be no more than 15 characters. Which check is this?

    1. Range check
    2. Length check
    3. Presence check
    4. 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.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

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? →

Related lessons