Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Validate length, presence and format

Use character count, required-field checks and pattern rules to reject incomplete or malformed input.

Cambridge IGCSE Computer Science 0478 · Algorithm design and problem-solving · 2026–2028 Version 6 · 7

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. 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.

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?

Put the idea to work

Worked example

A membership code must contain exactly eight characters and cannot be blank. Which checks apply?

Show the worked solution
  1. Check that the field is present.
  2. Count the characters.
  3. 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.

1 · Guided

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
  1. Presence check rejects an empty field.
  2. Length check counts characters.
  3. 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
2 · Independent

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
  1. State the required sequence of character classes.
  2. Compare the entered text with that pattern.
  3. 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
3 · Transfer

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
  1. The string has the expected DD/MM/YYYY shape.
  2. The calendar combination is invalid.
  3. 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
Recall without your notes

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.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.