1. Presence, type, length and format checks
Validation is a check that the data entered obeys a rule. It tests whether data is allowed. It does not test whether data is correct.
A presence check tests that there is data present in this field, so it cannot be left empty. A type check tests that data is of the right type, such as numeric or text only. A length check tests the number of characters, such as exactly 7 characters. A format check tests a pattern, such as two letters followed by 5 digits.
Use the check the context supports. A length check needs a known length and a format check needs a known pattern. A telephone number with a leading zero is held as text, not as a number.
Examiner insight
Worked example 14 marks
A college database contains details about students. Part of the database is in the table.
Identify and describe two validation checks that are suitable to use on the StudentID field.
| StudentID | FirstName | FamilyName | PhoneNumber |
|---|---|---|---|
| AB37689 | Mohammed | Abbas | 016324908367 |
| AH83965 | Jonathan | Olsen | 016328332901 |
| BV72189 | Suzanne | Usher | 016325599100 |
| DY64817 | Hua | Owyang | 016323652331 |
| KT52964 | Isabella | Mancini | 016328899477 |
| PS54200 | Ben | Quansah | 016329677901 |
- 1
Length check [1]
- 2
checks that the length of the data is exactly 7 characters [1]
- 3
Format check [1]
- 4
checks that each item begins with two letters followed by 5 digits [1]