Validate length, presence and format
Use character count, required-field checks and pattern rules to reject incomplete or malformed input.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers subject content Topic 7 only. The separately published 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- No programming language is required. Be comfortable with place value and multiplication; each lesson introduces the computer-science notation it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
Which check would require a code to have 8 characters?
What you will learn
- Explain a length check
- Explain a presence check
- Explain a format check
Different checks test different properties
A length check ensures that text contains the required number of characters or falls within a permitted length. A presence check ensures a required field has not been left blank.
Apply and check the rule
A format check tests whether data follows a pattern, such as a date written in the required order or a code with letters followed by digits. A format check does not necessarily prove that the represented real-world fact is correct.
Pause and explain
A date must use DD/MM/YYYY. Which check tests that pattern?
Worked example
A membership code must contain exactly eight characters and cannot be blank. Which checks apply?
Show the worked solution
- Check that the field is present.
- Count the characters.
- Require length eight.
Answer Use a presence check and a length check requiring exactly eight characters.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A username is required and must be 5–12 characters. Name the checks.
Give me a hint
One check handles blank values; another checks character count.
Compare my reasoning
- Presence check rejects an empty field.
- Length check counts characters.
- Accept lengths from 5 through 12.
Use a presence check and a length check from 5 to 12 characters inclusive.
Look for these in your work
- Presence
- Length
- Bounds
A postcode field expects two letters followed by four digits. Which validation check can test its shape?
Give me a hint
Describe the expected character pattern.
Compare my reasoning
- State the required sequence of character classes.
- Compare the entered text with that pattern.
- Reject entries that do not follow it.
Use a format check for two letters followed by four digits.
Look for these in your work
- Pattern stated
- Format check
- Rejection
An input matches the format 31/02/2026 but that date does not exist. Explain what additional rule or check is needed.
Give me a hint
A pattern check may accept impossible values.
Compare my reasoning
- The string has the expected DD/MM/YYYY shape.
- The calendar combination is invalid.
- Validate the actual day against the selected month and leap-year rules.
The format check is not enough. Check that the day exists in that month and year, including leap-year rules for February.
Look for these in your work
- Format limitation
- Invalid date
- Semantic check
Common mistakes
- Treating a syntactically valid date as a verified event
- Confusing a length check with a range check
What can you explain now?
Which check ensures a mandatory field is not empty?
Compare with the explanation
Presence check
The field must contain an entered value.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
What does a length, presence or format check test?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.