6.2.1 Checking Data During Entry
Data integrity can be damaged at the moment data enters a system. A value may be missing, badly structured, outside an acceptable boundary, copied incorrectly, or inconsistent with a known list of valid items.
This section examines two complementary approaches. Validation applies rules to the entered value. Verification checks whether the value entered matches the source or the user's intended entry.
By the end of this section, you should be able to:
- Explain the difference between validation and verification.
- Describe and apply range, limit, format, length, presence, existence, and check-digit checks.
- Select suitable validation rules for different input fields.
- Describe visual checking and double entry as verification methods.
- Explain why a value can pass every check and still be factually wrong.
Validation and Verification Answer Different Questions
| Method | Main question | Example | What it cannot prove |
|---|---|---|---|
| Validation | Does the value obey the field's rules? | An age of 17 is accepted because the permitted range is 13 to 19. | That the person is genuinely 17. |
| Verification | Was the source or intended value entered as expected? | A booking code is entered twice and both entries match. | That the original booking code was itself correct. |
Choosing Checks for a Field
A useful validation rule must reflect the meaning and expected structure of the field. Some fields need more than one check. For example, a membership code could require a presence check, a format check, a length check, and a check digit.
| Question about the field | Likely check |
|---|---|
| Must a value be supplied? | Presence check |
| Must the value stay between two boundaries? | Range check |
| Must it stay below or above one boundary? | Limit check |
| Must characters appear in a particular pattern? | Format check |
| Must it contain a fixed or permitted number of characters? | Length check |
| Must the value already occur in a stored list or table? | Existence check |
| Does an identifier contain a calculated final digit? | Check-digit check |
Range Checks and Limit Checks
Range check
A range check compares a value with both a lower boundary and an upper boundary. Values inside the permitted interval are accepted.
A youth sailing course accepts participants aged from 14 to 18 inclusive. The entry 19 fails because it is above the permitted range. The entry 16 passes, although this alone does not prove that the participant is truly 16.
Limit check
A limit check compares a value with one boundary only. It may enforce a maximum or a minimum.
A courier form allows a parcel mass of no more than 22 kg. An entry of 24.5 kg fails the upper-limit check. No lower boundary is being tested by this rule.
Format, Length and Presence Checks
| Check | What it tests | Original field rule | Example that fails |
|---|---|---|---|
| Format check | The arrangement and type of characters | Workshop code must follow AA-999 | R7-42B |
| Length check | The number of characters | Library locker code must contain exactly 8 characters | LK20491 contains 7 characters |
| Presence check | Whether a required field has been left empty | Emergency contact number must not be blank | An empty input field |
Existence Check
An existence check compares the entered value with data already stored by the system. It is useful when the value should refer to a known record, item, route, account, or product.
Original example: minibus route code
A booking system stores the valid route codes MB12, MB18, MB24, and MB31. The entry MB27 has the correct pattern and length, but it fails the existence check because no such route is stored.
Check Digit
A check digit is calculated from the other digits in an identifier. When the identifier is entered, the system repeats the calculation and compares the result with the supplied final digit. A mismatch suggests that the identifier was entered incorrectly.
Original training scheme
The following invented scheme is used only to demonstrate the process:
- Multiply four base digits by the weights 4, 3, 2, and 1.
- Add the products.
- The final digit is the remainder after division by 10.
| Base digit | 3 | 8 | 1 | 6 |
|---|---|---|---|---|
| Weight | 4 | 3 | 2 | 1 |
| Product | 12 | 24 | 2 | 6 |
The total is 44, so the check digit is 4. The complete identifier is therefore 38164.
If a user enters 38194, the recalculated total for the first four digits is 47, so the expected check digit is 7. The supplied final digit is 4, so the entry fails.
Verification During Data Entry
Visual check
The entered value is displayed and compared with the original source. A person identifies and corrects any difference.
Double entry
The same data is entered independently for a second time. The computer compares the two entries. If they differ, the user must correct or repeat the input.
| Method | Example | Strength | Limitation |
|---|---|---|---|
| Visual check | A volunteer compares the displayed name with a signed paper form. | Useful for many different kinds of field. | A person may overlook the difference. |
| Double entry | An email address is typed twice and the system compares both versions. | Automatically detects disagreement between the entries. | The same mistake could be made twice. |
Worked Example: Designing Checks for an Entry Form
Scenario
A regional robotics event records a team name, division code, number of team members, supervisor email, and school identifier.
| Field | Rule | Suitable check | Reason |
|---|---|---|---|
| Team name | Must not be empty | Presence check | A record cannot be identified without a name. |
| Division code | Must be one of JR, INT, or ADV | Existence check | The value must occur in the stored list of divisions. |
| Team members | From 3 to 7 inclusive | Range check | Both a minimum and maximum apply. |
| Supervisor email | Must be entered twice | Double-entry verification | The two entries can be compared for agreement. |
| School identifier | Four base digits plus a calculated final digit | Check-digit validation | A recalculation can detect some entry errors. |
Interactive: Data Entry Check Simulator
Choose an input situation and select the check that most directly detects the problem. The flow display shows the value, the chosen method, and the expected outcome.
Common Mistakes and Misconceptions
- Claiming that validation guarantees accuracy.
- Confusing a range check, which uses two boundaries, with a limit check, which uses one.
- Confusing presence with existence.
- Using length check when the important rule is the pattern of characters.
- Classifying visual checking or double entry as validation.
- Assuming double entry cannot repeat the same mistake twice.
- Calling a check digit a checksum; checksums belong to transfer checking in the next section.
Practice
Try these original questions
- Explain one difference between validation and verification.
- A field accepts temperatures from β12Β°C to 46Β°C. Name and describe the most suitable check.
- A lift booking permits a maximum load of 850 kg. Name and describe the most suitable check.
- A specimen code must follow the pattern AAA-9999. Explain how a format check would be used.
- Explain the difference between a presence check and an existence check.
- Describe how a check digit can detect an incorrectly entered identifier.
- Explain how a visual check could be applied when transferring data from a paper survey.
- Describe double-entry verification and give one limitation.
- A value of 15 passes an age range of 12 to 17, but the person is actually 19. Explain why validation did not protect data integrity in this case.
- Design suitable entry checks for a music festival form containing a stage code, performer count, required contact name, and ticket batch identifier.
Review
| Method | Strong recall statement |
|---|---|
| Range check | Tests a value against both a minimum and maximum. |
| Limit check | Tests a value against one upper or lower boundary. |
| Format check | Tests whether characters follow a required pattern. |
| Length check | Tests the number of characters. |
| Presence check | Tests whether a required field is empty. |
| Existence check | Tests whether a value occurs in a stored valid list or table. |
| Check digit | Recalculates a digit from the rest of an identifier and compares the result. |
| Visual check | Compares displayed entered data with the source. |
| Double entry | Enters data twice and compares the two versions. |