Validation: why data is checked on entry

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Validation: why data is checked on entry

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A form refuses to accept the text 'abc' in an Age box. What is this an example of?
A Validation: an automatic check on entry
B Verification: proving the age is true
2. Which statement about validation is correct?
A It guarantees every entry is true
B It stops bad data before it spoils later results
3. A student is 15 but types 16 in an Age field. The validation rule is 'whole number from 10 to 18'. What happens?
A It is rejected because the age is not true
B It passes validation, but the data is still wrong
4. Which check is verification rather than validation?
A Typing your email twice to confirm it matches
B Blocking a date typed as 'banana'
5. When is validation applied to data?
A When the data is entered
B Only after all the results are calculated

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Age must be between 10 and 100 AAge rule: 10 to 100. Typed: 15. Real age: 16. Result: accepted
2Please type your email address again BValidation should happen when data is entered. Checking late lets bad data spoil results such as totals and averages before it is caught.
3Valid but wrong data: a rule can accept an age of 15 even when the person is really 16, because validation only checks that data is reasonable CA range check: the system rejects any age outside the allowed range when it is typed in
4Rejecting versus warning: a strict rule blocks bad data and a softer rule lets the user continue after a message DStop: value rejected / Warning: value allowed after a message
5Validation proved the age 15 was true, so no more checking is needed EValidation only checks that data is reasonable and in the right form. It cannot prove the data is true, so a valid age can still be wrong.
6Check data for errors only at the end, after all the results are worked out FVerification: the user re-enters the data so the two entries can be compared for typing mistakes

Definitions

validation

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
=IF(___(B2>=10,B2<=18),"Valid","Invalid")
2.
age ← 15 IF age >= 0 AND age __ 120 THEN OUTPUT "Valid"
3.
IF mark <= 100 THEN OUTPUT "Saved" ____ OUTPUT "Rejected: 0 to 100 only"
4.
IF age < 0 __ age > 120 THEN OUTPUT "Warning: check this age"
5.
=IF(B2_C2,"Match","Re-check")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A INPUT age
B IF age>=10 OR age<=18 THEN
C ACCEPT age
D ELSE
E REJECT age
Question 2
A INPUT postcode
B n <- LENGTH(postcode)
C IF n > 4 THEN SAVE postcode
D ELSE REJECT postcode
Question 3
A INPUT name
B IF name <> "" THEN
C SHOW "Name is required"
D ELSE SAVE name
Question 4
A // typed score 85, real is 58
B IF score >= 0 AND score <= 10
C PRINT "Accepted as valid"
D // Valid does not mean true
Question 5
A INPUT height_cm
B IF height_cm < 0 THEN
C WARN "Cannot be negative"
D ELSE IF height_cm > 220 THEN
E WARN "Unusual - check it"

Answer Key

Validation: why data is checked on entry
Section A: Quick Questions
Q1
A — Validation: an automatic check on entry
Q2
B — It stops bad data before it spoils later results
Q3
B — It passes validation, but the data is still wrong
Q4
A — Typing your email twice to confirm it matches
Q5
A — When the data is entered
Section B: Match the Pairs
Q1
Age must be between 10 and 100 → A range check: the system rejects any age outside the allowed range when it is typed in
Q2
Please type your email address again → Verification: the user re-enters the data so the two entries can be compared for typing mistakes
Q3
Valid but wrong data: a rule can accept an age of 15 even when the person is really 16, because validation only checks that data is reasonable → Age rule: 10 to 100. Typed: 15. Real age: 16. Result: accepted
Q4
Rejecting versus warning: a strict rule blocks bad data and a softer rule lets the user continue after a message → Stop: value rejected / Warning: value allowed after a message
Q5
Validation proved the age 15 was true, so no more checking is needed → Validation only checks that data is reasonable and in the right form. It cannot prove the data is true, so a valid age can still be wrong.
Q6
Check data for errors only at the end, after all the results are worked out → Validation should happen when data is entered. Checking late lets bad data spoil results such as totals and averages before it is caught.
Section C: Definitions
Q1
validation — An automatic check that data is reasonable and in the right form when entered. It blocks bad data early, but it cannot prove the data is true (a valid age of 15 could still be wrong).
Section D: Fill in the Blanks
Q1
=IF(AND(B2>=10,B2<=18),"Valid","Invalid")
Q2
age ← 15 IF age >= 0 AND age <= 120 THEN OUTPUT "Valid"
Q3
IF mark <= 100 THEN OUTPUT "Saved" ELSE OUTPUT "Rejected: 0 to 100 only"
Q4
IF age < 0 OR age > 120 THEN OUTPUT "Warning: check this age"
Q5
=IF(B2=C2,"Match","Re-check")
Section E: Spot the Error
Q1
B — A range check needs AND so the age must be both at least 10 and at most 18. With OR, every number passes, so the check never blocks bad data.
Q2
C — This is a length check. Australian postcodes have exactly 4 digits, so the test should be n = 4. Using n > 4 would accept only longer, invalid entries.
Q3
B — A presence check should catch an EMPTY entry. With <> the error message would show when a name was typed. It should be IF name = "" THEN.
Q4
B — The upper limit of the range check should be 100 so that 85 passes. 85 is valid but still wrong, because validation only checks that data is reasonable and cannot prove it is true.
Q5
C — A negative height is impossible, so it should be rejected, not just warned about. Warnings are for unusual values that could still be true.