AQA · GCSE · Computer Science
Course version: 8525 · Version from Sept 2020
Checking if an entered string has a minimum length
Full specification wording
Robust and secure programming: checking if an entered string has a minimum length
A minimum-length check is a simple validation routine: it measures how many characters an entered string contains and rejects it if that count is below a set limit.
Checked against the AQA 8525 specification (opens in a new tab) on .
- Point 1 of 14
Study notes
From the checked teaching notes for this specification point.
The idea
A minimum-length check is a simple validation routine: it measures how many characters an entered string contains and rejects it if that count is below a set limit. The program stores the input, compares its length with the minimum, and if the length is too small it refuses the value and asks again. For example, a username rule of at least six characters rejects a three-character entry but accepts a six-character one. The check concerns length only; it does not test whether characters are letters, digits or symbols, so a long string of spaces could still pass unless other rules are added. In a multiple-choice question, identify the option that compares the string's length with a minimum and acts on the result.
What earns the marks
- States that the routine counts or measures the number of characters in the entered string.
- States that the measured length is compared with a defined minimum value.
- States that input shorter than the minimum is rejected, and the user is asked to re-enter.
- Recognises that the check tests length only and does not judge the type or content of characters.
- Identifies that input meeting or exceeding the minimum passes this particular check.
Common mistakes and how to put them right
Confusing minimum length with a range or maximum check.
Put it right: Minimum length sets a lower limit only, so longer strings pass.
Thinking the check tests whether characters are valid letters or digits.
Put it right: That is a separate character-type or presence check.
Believing the program silently stores short input.
Put it right: The routine should reject it and prompt for re-entry.
Exam tips
- Look for the option that compares character count with a minimum and then accepts or rejects accordingly.
- Rule out options describing presence, range or format checks, since those test different properties.
- Use a quick example, such as rejecting a three-character username against a six-character minimum, to confirm your choice.
Try the lesson
The start of the Robust and secure programming: checking if an entered string has a minimum length lesson, made from checked teaching notes for this specification point.
Have a go first
A program asks the user to enter a username and must reject it if it is shorter than 6 characters. Which check is being carried out?
There is more to this lesson
The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge
Test your understanding of Robust and secure programming: checking if an entered string has a minimum length
Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.
A week of Premium from your first lesson · Then the free plan continues · No card, no charge