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.
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.
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
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?
What is the purpose of validation?
What normally happens when input fails a validation check?
Range check
Type check
Length check
Presence check
Format check
Can one input have more than one validation check?
Does data that passes validation have to be correct?
Quick test: is 'from 1 to 10' a range check or a length check?
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 postedMore Eduqas GCSE Computer Science topics
- CPU performance: cache size and levels
- CPU performance: clock speed
- CPU registers
- Cryptographic utilities
- Current instruction register (CIR)
- Data interception and theft
- Data verification
- Debugger
- Denary, binary and hexadecimal counting
- Denial of service attacks
- Digital storage of characters
- Digital storage of graphics
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.