In computer science, data validation is the process of ensuring that a program operates on clean, correct and useful data. It may use routines that check for correctness or meaningfulness of data input to the system.
The simplest data validation verifies that the characters provided come from a valid set. For example, telephone numbers should include the digits and possibly the characters +, -, ( and ) (plus, minus and the parentheses). A more sophisticated data validation routine would check to see the user has entered a valid country code; the number of digits entered matches the convention for the country or area specified, etc.
Incorrect data validation can lead to data corruption or a security vulnerability.
Data validation checks that the data is valid and sensible/reasonable before it is processed.
Methods used for validation are...
- range check
This checks that the data lies within a specified range of values. Eg the month of a person's DOB should lie between 1 and 12
- presence check
This checks that important data is actually there and has not been missed out. Eg Customers may be required to have their telephone numbers.
- check digits
Used for numerical data. An extra digit is added to a number which is calculated from the digits. The computer checks this calculation when data is entered. Eg The ISBN number on a book. The last digit is a check digit.
- batch totals
This checks for missing records. Numerical fields may be added together for all records in a batch. The batch total is entered and the computer checks that the total is correct. Eg Add the 'Total Cost' field of a number of transactions together.
- hash totals
This is just a batch total done on one or more numeric fields which appears in every record. Eg Add the Telephone Numbers together for a number of Customers.
http://www.thevickerage.worldonline.co.uk/theteacher/newgcse/module5/task10.htm