AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Right data and quick finds

Week 17 · Unit 7: Be a data engineer · 3 lessons
2

Stopping wrong data

Computing 5: Unit 7, pp. 86–103
GoalExplain how a validation rule limits what can be typed in a cell, and write rules for type, length and range.
New words
validation · a check that a spreadsheet makes on data when it is typedvalidation rule · a rule that data must follow, such as ‘a whole number from 1 to 99’error message · a message that says the data was refused and what to type insteadvalid · data that follows the rule
Explanation

Data validation checks data when it is typed. We select the cells and choose a rule. A rule can limit the data type, such as ‘a date’. It can limit the length of text, such as ‘exactly 5 characters’. It can limit the range of a number, such as ‘a whole number from 1 to 99’. If the data breaks the rule, the spreadsheet refuses it and shows an error message. Validation cannot tell whether data is true. A shirt number of 71 is valid even when the player wears 17, so important data must still be checked.

Starttype data in the celldata follows the rule?yesnoaccept the datashow an error messageEnd
Worked examples
FieldEntryAccepted?Why
Kit codeK-101yes5 characters
Kit codeK-1012no6 characters
Number in store250nomore than 200
Number in storefortynonot a number
Date bought12 Feb 2026yesa date
The kit store sheet has three rules. Kit code: text, exactly 5 characters. Number in store: a whole number from 0 to 200. Date bought: a date. Here is what happens to some entries.
Poor messageBetter message
ErrorType a whole number from 0 to 200.
Not allowedThe kit code needs exactly 5 characters.
WrongPlease type a date, such as 12 Feb 2026.
A clear error message helps the person to fix the mistake.
PlayerReal shirt numberTypedValid?Correct?
Dina1717yesyes
Omar1771yesno
A validation rule cannot find every mistake. The shirt number rule is a whole number from 1 to 99. Both entries are valid, but only one is right.
Class activity

Gatekeeper (3 or more players). One player is the gatekeeper and holds a rule card, such as ‘a whole number from 1 to 12’. The other players hand over slips of paper with entries: 7, 13, July, 3.5, 12. The gatekeeper accepts or refuses each slip and, if refusing, reads out a helpful error message. Then change the rule, for example to ‘text of exactly 4 letters’. Invent rules of your own for a library card or a sports club. Which rules were hard to explain in a message?

Practice
1
The rule for ‘Page number’ is a whole number from 1 to 30. Which of these are accepted? 5, 31, 0, 12.5, 30
FieldRule
Page numberwhole number from 1 to 30
2
Write a validation rule for each field: (a) age of club members, who are 5 to 12 years old, (b) a locker code of four characters, (c) the date of a match.
3
Which entry will cause an error?
FieldRuleEntries
Team codetext, exactly 3 charactersLIO, TIGER, FOX
4
Write a helpful error message for a cell that accepts whole numbers from 0 to 50.