Data validation is the process of ensuring that the data entered into a system meets certain criteria and is both accurate and useful. Proper data validation checks prevent errors and ensure that data conforms to specific rules.
Types of validation
Presence check. A presence check makes sure that a critical field cannot be left blank, it must be filled in. If someone tries to leave the field blank then an error message will appear and you won't be able to progress to another record or save any other data which you have entered.
Range check. Ensures that data is within a defined range. A range check is commonly used when you are working with data which consists of numbers, currency or dates/times.
Testing with normal, extreme and abnormal data. Imagine we are testing a text box to make sure that it will only accept entries of numbers between 1 and 5. The test data would look like this:
Type check. A type check will ensure that the correct type of data is entered into that field. For example, in a clothes shop, dress sizes may range from 8 to 18. A number data type would be a suitable choice for this data. By setting the data type as a number, only numbers could be entered e.g. 10, 12, 14 and you would prevent anyone trying to enter text such as ‘ten’ or ‘ten and a half’.
Length check. Sometimes you may have a set of data which always has the same number of characters. For example, a password might need to be between 8 and 16 characters long.
Format check. Some types of data will always consist of the same pattern.
Think about a postcode. The majority of postcodes look something like this:
CV36 7TP
WR14 5WB
Replace either of those examples with L for any letter which appears and N for any number that appears and you will end up with:
LLNN NLL
This means that you can set up a format check for something like a postcode field to ensure that a letter isn't entered where a number should be or vice versa.
Example 2A National Insurance number must be in the form of XX 99 99 99 X. The first two and the last characters must be letters. The other six characters are numbers. Any format entered differently to this will be rejected.
Check digit. This is used when you want to be sure that a range of numbers has been entered correctly.
Algorithm for calculating the check digit:
1. Add all the digits in even numbered positions together.
2. Multiply the result above by 3.
3. Add all the digits in odd numbered positions together.
4. Add results (2) and (3) together.
5. Calculate the remainder (modulo 10) of result (4).
6. Subtract (5) above from 10
Exercise 1:
Calculate the check digit of the following ISBN (International Standard Book Number):
9 7 8 0 9 5 7 3 4 0 4 1 - 1
where the last one is the check digit.
Different types of check may be used on the same piece of data; for example, an examination mark could be checked for reasonableness by using a range check, a type check and a presence check. When data is validated by a computer system, if the data is rejected a message should be output explaining why the data was rejected and another opportunity given to enter the data.
Verification is checking that data has been accurately copied onto the computer or transferred from one part of a computer system to another.
Verification methods include:
Double entry.
Screen/visual check.
For double entry the data is entered twice, sometimes by different operators; the computer system compares both entries and outputs an error message requesting that the data is entered again if they are different.
A screen/visual check is a manual check completed by the user who is entering the data. When the data entry is complete the data is displayed on the screen and the user is asked to confirm that it is correct before continuing. The user checks the data on the screen against a paper document that is being used as an input form or confirms from their own knowledge if the data is about them.