Graphic showing a validation error online

Databasefields should have validation rules to make sure the data entered follows the expected format.

There are different types of validation checks a database can run:

Validation typeHow it worksExample
Check digitThe last couple of digits can be used as a 'check sum' that can detect if errors have occurredBar code readers in shops
Type checkChecks the data is in the right formatNumbers in currency cell must be a monetary value with two decimal points
Length checkChecks the data is an acceptable lengthA PIN for online banking needs to be four (or six) characters long
Lookup tableChecks that the value provided matches an item in a set listA limited set of values, such as the seven 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 rangeAn online gift certificate purchase must be more than or equal to £5 but less than or equal to £50
Spell checkLooks up words in a dictionaryA search engine often recommends a correct spelling if a word is spelt wrong
Input maskChecks that data has been entered with the correct amount of characters and/or numbersNational insurance numbers need to be in the format: YY XX XX XX Y, where Y = letter and X = number
DuplicateChecks that a value has not been repeatedA primary key value can only be entered once

The computer will use these rules to check whether the data entered is correct. If it is invalid an error message will be created.

Move on to Test