Validation
For example, a secondary school student is likely to be aged between 11 and 16. The computer can be programmed only to accept numbers between 11 and 16. This is a range check.
However, this does not guarantee that the number typed in is correct. For example, a student's age might be 14, but if 11 is entered it will be valid but incorrect.
Types of validation
There are a number of validation types that can be used to check the data that is being entered.
Validation type | How it works | Example usage |
Check digit | The last one or two digits in a code are used to check the other digits are correct | Bar code readers in supermarkets use check digits |
Format check | Checks the data is in the right format | A National Insurance number is in the form LL 99 99 99 L where L is any letter and 9 is any number. The currency of the UK is GBP or Pound Sterling (eg 拢23.45) but in the USA the currency is USD or US Dollar (eg $5.20). A date can be formatted in different formats, eg 28/01/1999; 28/1/99; 28 January 1999. |
Length check | Checks the data isn't too short or too long | A password which needs to be six letters long |
Lookup table | Looks up acceptable values in a table | There are only seven possible days of the week |
Presence check | Checks that data has been entered into a field | In most databases a key field cannot be left blank |
Range check | Checks that a value falls within the specified range | Number of hours worked must be less than 50 and more than 0 |
Spell check | Looks up words in a dictionary | When word processing |
Validation type | Check digit |
---|---|
How it works | The last one or two digits in a code are used to check the other digits are correct |
Example usage | Bar code readers in supermarkets use check digits |
Validation type | Format check |
---|---|
How it works | Checks the data is in the right format |
Example usage | A National Insurance number is in the form LL 99 99 99 L where L is any letter and 9 is any number. The currency of the UK is GBP or Pound Sterling (eg 拢23.45) but in the USA the currency is USD or US Dollar (eg $5.20). A date can be formatted in different formats, eg 28/01/1999; 28/1/99; 28 January 1999. |
Validation type | Length check |
---|---|
How it works | Checks the data isn't too short or too long |
Example usage | A password which needs to be six letters long |
Validation type | Lookup table |
---|---|
How it works | Looks up acceptable values in a table |
Example usage | There are only seven possible days of the week |
Validation type | Presence check |
---|---|
How it works | Checks that data has been entered into a field |
Example usage | In most databases a key field cannot be left blank |
Validation type | Range check |
---|---|
How it works | Checks that a value falls within the specified range |
Example usage | Number of hours worked must be less than 50 and more than 0 |
Validation type | Spell check |
---|---|
How it works | Looks up words in a dictionary |
Example usage | When word processing |