鶹Լ

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.

Example of validation error in high school database. School is visible through the window

Types of validation

There are a number of validation types that can be used to check the data that is being entered.

Validation typeHow it worksExample usage
Check digitThe last one or two digits in a code are used to check the other digits are correctBar code readers in supermarkets use check digits
Format checkChecks the data is in the right formatA 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 checkChecks the data isn't too short or too longA password which needs to be six letters long
Lookup tableLooks up acceptable values in a tableThere are only seven possible days of the week
Presence checkChecks that data has been entered into a fieldIn most databases a key field cannot be left blank
Range checkChecks that a value falls within the specified rangeNumber of hours worked must be less than 50 and more than 0
Validation typeCheck digit
How it worksThe last one or two digits in a code are used to check the other digits are correct
Example usageBar code readers in supermarkets use check digits
Validation typeFormat check
How it worksChecks the data is in the right format
Example usageA 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 typeLength check
How it worksChecks the data isn't too short or too long
Example usageA password which needs to be six letters long
Validation typeLookup table
How it worksLooks up acceptable values in a table
Example usageThere are only seven possible days of the week
Validation typePresence check
How it worksChecks that data has been entered into a field
Example usageIn most databases a key field cannot be left blank
Validation typeRange check
How it worksChecks that a value falls within the specified range
Example usageNumber of hours worked must be less than 50 and more than 0

More guides on this topic