The age of minus four
A sign-up form accepts an age of minus four. It accepts a room number of "banana". It lets a name stay empty.
A few simple checks would have stopped all three. Auditing means checking that data is clean, correct and useful, both as it goes in and after it is stored.
Key words
| Word | What it means | Example |
|---|---|---|
| Audit | To check that data is clean, correct and useful. | Review a table each term |
| Validation | A check that data is sensible and in the right shape. | Age must be 11 to 18 |
| Verification | A check that data is the same as the original or was copied correctly. | Compare with the paper form |
| Check digit | A digit added to a number, worked out from the others, to catch typing errors. | The last digit of 1236 |
| Format check | Checks that data follows a set pattern. | Two letters, four digits |
| Length check | Checks that data is not too short or too long. | Exactly 6 characters |
| Presence check | Checks that a required field is not empty. | Name is filled in |
| Range check | Checks that a number is between two limits. | Age from 11 to 18 |
| Lookup table | A list of allowed values to check against. | Allowed room names |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can name four verification methods and six validation checks, and say which one fits a problem.
Starter: what you already know
Have a go
Starter: what you already know
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Four ways to verify
| Method | What you do |
|---|---|
| Cross-checking | Compare the data with a second copy or source |
| Review against external systems | Check it agrees with the original data held elsewhere |
| Quality assurance | A planned set of checks, done by a second person |
| Spell check | Find mistyped words |
The cells students fill in are left blank in this preview.
Six ways to validate
| Check | What it tests | Example |
|---|---|---|
| Presence | Is it filled in? | Name is not empty |
| Range | Is it between two limits? | Age 11 to 18 |
| Length | Is it the right length? | Code has 6 characters |
| Format | Does it follow the pattern? | AB1234 |
| Lookup | Is it on the allowed list? | Room R12 |
| Check digit | Does the last digit fit the others? | 1236 |
The cells students fill in are left blank in this preview.
Try it: three checks
age = -4
name = ""
room = "banana"
rooms = ["R11", "R12"]
print("Range ok:", age >= 11 and age <= 18)
print("Presence ok:", name != "")
print("Lookup ok:", room in rooms)
# Try it: set age to 15, name to "Sam" and room to "R12", then press Run.
A common mistake
Warning
Many people think a passed validation proves the data is right. Age 17 passes the range check even if the person is 12. Validation only catches the impossible. Verification catches more.