Validation rule
From Wikipedia, the free encyclopedia
This process is carried out after the data has been encoded onto an input medium and involves a data vet or validation program. Its purpose is to check that data falls within certain parameters defined by the systems analyst. A judgement as to whether data is valid is made possible by the validation program, but it cannot ensure complete accuracy. This can only be achieved through the use of all the clerical and computer controls built into the system at the design stage. The difference between validity and accuracy can be illustrated with a simple example. A company has established a Personnel file and each record contains a field for the Job Grade. The permitted values are A, B, C, or D. An entry in a record may be valid and accepted by the system if it is one of these characters, but it may not be the correct grade for the individual worker concerned. Whether a grade is correct can only be established by clerical checks or by reference to other files. During systems design, therefore, data definitions should be established which place limits on what constitutes valid data. Using these data definitions, a range of software validation checks can be carried out. Some typical validation checks are outlined below.
Size. The number of characters in a data item value is checked; for example, a stock code may consist of 8 characters only.
Range. Data must lie within maximum and minimum values. For example, customer account numbers may be restricted within the values 00001 to 10000.
Format checks. Data must conform to a specified format. Thus, a stock code designated as having 2 alphabetic characters, followed by 4 numeric digits must always be entered this way. Any other arrangement is rejected.
Consistency. Data items which are related in some way can be checked for the consistency of their relationship. For example, in a personnel file, any employee aged 25 years or over must be contributing to the company superannuation scheme. Conversely, employees under the age of 25 years cannot be members of the superannuation scheme. Any record which does not show such consistency indicates that either the age or the superannuation entry is incorrect.
Check digit. An extra digit calculated on, for example, an account number, can be used as a self-checking device. When the number is input to the computer, the validation program carries out a calculation similar to that used to generate the check digit originally and thus checks its validity. This kind of check will highlight transcription errors where two or more digits have been transposed or put in the wrong order. One of the commonest methods of producing a check digit is the modulus 11 algorithm. The following example serves to illustrate its operation.
Consider a stock code consisting of six digits, for example 462137.
The check digit is calculated as follows:
1.
Each digit of the stock code is multiplied by its own weight. Each digit has a weight relative to its position, assuming the presence of a check digit in the rightmost position. Beginning from the check digit (x) position the digits are weighted 1, 2, 3, 4, 5, 6 and 7 respectively as shown in Table 1.
2.
The products are totalled. In this example, the sum produces 101.
3.
Divide the sum by modulus 11. This produces 9, remainder 2.
4.
Subtracting the remainder 2 from 11 gives a check digit of 9.
Whenever, a code is entered with the relevant check digit, the validation software carries out the same algorithm, including the check digit in the calculation. Provided that the third stage produces a remainder of zero the code is accepted as valid. This is proved in Table 2, using the same example as above.
The sum of the products is 110, which when divided by 11, gives 10, remainder 0. Therefore, the number is valid.
If some of the digits are transposed (swapped around) the check digit is no longer applicable to the code and is rejected by the validation program because the results of the algorithm will not leave a remainder of zero. This is shown in Table 3.
The sum of the products equals 111, which when divided by 11, gives 10, remainder 1. The number is, therefore, invalid. Validation rules stop invalid data being put into a field