GCSE · Computer Science · Eduqas · Spec C500QS

Data validation

Leave a required box empty and the page tells you off. Nobody is watching: the program is checking, and you're about to be the program.

Computer Science · Validation

Be the program

An example quantity field: it must not be left blank, and the number must be from 1 to 10, with both 1 and 10 allowed. Pick a set of inputs, then call each diamond before you press Next.

Step 1. The routine starts. It will ask for a quantity.

Step 1 of 6Called right: 0 of 2

Computer Science · Validation

Which check is this rule?

Each of these is an example rule for a form field. Pick a rule, then pick the check that rule is.

Still to sort

Range check (0)

The value lies between a lower and an upper limit.

Where the line is: Range tests the size of the value. Length counts characters, so 10 has two characters but is still within 1 to 10.

Type check (0)

The data is the expected data type, such as a whole number.

Where the line is: Type asks what kind of data it is. Format asks whether the characters follow a pattern.

Length check (0)

The number of characters is within a limit, or exactly the number required.

Where the line is: Length counts characters. It never tests what the characters are.

Presence check (0)

Something has actually been entered.

Where the line is: Presence only asks whether the box was left blank. It doesn't judge what was typed.

Format check (0)

The characters match a required pattern.

Where the line is: Format is about the pattern, such as DD/MM/YYYY, rather than the size or the data type.

10 of 10 still to sort.

Exam line: Name the check by what it tests: value between limits is range, kind of data is type, number of characters is length, something entered is presence, pattern of characters is format.
Watch out: A rule about a number can still be a length check if it counts characters rather than testing the value.

Computer Science · Validation

It passed. So it's right, yes?

An example booking form asks for the number of guests, from 1 to 10. Maya meant to type 3, but her finger slipped and she typed 7. The form accepts it.

Which of these is closest to what you think?
How sure are you?

Exam line: Valid means the data passed the checks. It does not mean the data is correct.

Computer Science · Validation

Which line rejects too much?

The rule says the number of guests can be 1 to 10, with both 1 and 10 allowed. This routine asks again for any value outside that rule. When a user types 10, they are told to try again. Which line is faulty?

A student's validation routine — which line goes wrong?

Exam line: If the rule includes a limit, the condition must let that limit through. Test the condition with a value sitting exactly on each limit.

Computer Science · Validation

Write it, then mark it

An example form has a field called 'Age in years'. It is required, and it must be a whole number.

State the purpose of validation. Then suggest two different validation checks for the 'Age in years' field and say what each would reject. [5 marks]

0 words · your answer stays on this page and is not sent anywhere.

Exam line: Name the check, then say what it rejects: 'A presence check rejects the field being left blank.'

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

How a program decides whether what you typed is allowed in, and what it can't know.

What you need to know

  • Data validation is an automatic check, run by the program, that input is sensible and follows set rules before it's accepted.
  • Its job is to cut the chance of bad data being accepted, so the program doesn't give wrong results or fail.
  • Input that fails a check is rejected. The user is normally given a message and asked to enter it again.
  • A range check tests that a value lies between a set lower and upper limit. The rule says whether the limits count.
  • Have a goA field has a range check: 1 to 10, and the rule says both limits are allowed. Someone types exactly 10. Accepted or rejected?

    Accepted.

    The rule defines whether the limits count. Here 10 is an allowed limit, so a value sitting exactly on it is inside the range.

  • A type check tests that data is the expected type, such as an integer field holding only a whole number.
  • A length check tests that the number of characters is within a set limit, or is exactly the number required.
  • A presence check tests that something has been entered, so a required field isn't left blank.
  • A format check tests that the data matches a required pattern of characters, such as DD/MM/YYYY.
  • Have a goYour mate Sam swears 'the code must be exactly 8 characters' is a format check, and won't be moved. Is Sam right?

    No. It's a length check.

    It counts how many characters there are. A format check tests whether the characters match a pattern, such as DD/MM/YYYY.

  • One input can have more than one check. A required numeric field might have a presence check and a range check.
  • Have a goA required number field has a presence check and a range check. The user types nothing at all. Which check should catch it?

    The presence check.

    Nothing was entered, and that's exactly what a presence check tests. Two checks can sit on one field, each doing its own job.

  • Passing validation doesn't prove data is correct. A sensible but mistyped value can be valid and still wrong.

The big picture

Data validation is an automatic check that input is sensible and follows set rules before it is accepted. There are five checks to know: range, type, length, presence and format. One input can have several checks. Failing a check means a message and another go. Passing every check still doesn't prove the data is correct.

Key points

1Validation is an automatic check that input is sensible and follows set rules before it is accepted.
2The five checks are range, type, length, presence and format, and each tests one thing.
3Failing input is rejected, and the user is normally given a message and asked to try again.
4More than one check can be applied to the same input.
5Valid doesn't mean correct: a sensible but mistyped value passes every check.

Worked example

Problem

An example 'Score' field is required, must be a whole number, and must be from 0 to 50. Decide what happens when a user types each of these: (nothing), ten, 50, 51.

⚠ Watch out

Mixing up range and length. A rule like 'from 1 to 10' tests the size of the value, so it's a range check. A length check counts characters. The number 10 has two characters, but it still passes a range of 1 to 10.

🧠

Memory hook

Validation is a bouncer checking the entry rules, not a mind reader. The bouncer can see that you meet the rules (right age, right dress code). The bouncer can't know whether you gave your real name.

✓

Check yourself

Name the five validation checks and what each tests. Which would reject an empty box, and which would reject 5 June 2011 on a DD/MM/YYYY field?

Flashcards

(11)
What is data validation?
An automatic check, carried out by a program or computer system, that input is sensible (reasonable) and follows set rules before it is accepted.
What is the purpose of validation?
To reduce the chance of invalid or unreasonable data being accepted and processed, so the program doesn't give wrong results or fail because of bad input.
What normally happens when input fails a validation check?
It is rejected, and the user is normally given a message and asked to enter the data again.
Range check
Tests that a value lies between a set lower limit and a set upper limit (inclusive or exclusive, as the rule defines).
Type check
Tests that the data entered is of the expected data type, for example that an integer field holds only a whole number.
Length check
Tests that the number of characters is within a set limit, or is exactly a required number of characters.
Presence check
Tests that data has actually been entered, so a required field isn't left blank.
Format check
Tests that the data matches a required pattern of characters, for example a date in the pattern DD/MM/YYYY.
Can one input have more than one validation check?
Yes. For example, a required numeric field may have both a presence check and a range check.
Does data that passes validation have to be correct?
No. Data can pass every check (be valid) and still be wrong, for example a sensible but mistyped value.
Quick test: is 'from 1 to 10' a range check or a length check?
A range check. It tests the size of the value against limits. A length check counts characters.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 15 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.