Professional Documents
Culture Documents
Validation and Verification
Validation and Verification
A computer system should accept only the required values for a scenario and reject all other values that
do not meet the requirement for that scenario. Two different checking methods are used to accomplish
this task. One is validation and the other one is verification. Both the methods are used during data
entry.
Validation: is a method which checks if the data is meaningful / reasonable / sensible / within the range
or meets the criteria that have been set. It is always an automated checking by a program before it is
accepted by a computer system. This process continues until an input value is given to the requirement
set by the program. There may be different types of validation checks that could be applied on same piece
of data.
For ensuring validation, conditional loops (WHILE or REPEAT) are always used.
Pseudocode example:
The following example will accept value within the range from 0 to 100 inclusive. If not then
program will not proceed further unless the acceptable value is given.
ii. Length check (used mainly for characters): It counts number of characters and checks if the
number of characters are of a fixed length or a reasonable length.
Page 1 of 6
// Pseudocode example of fixed length
INPUT Password
WHILE LENGTH(Password) < > 10 DO
OUTPUT “Password must be exactly 10 characters long”
INPUT Password
ENDWHILE
N.B. LENGTH() function which is used for STRING data type counts and returns number of
characters for a variable
iii. Type check: Checks whether the data is of any particular type or not. For example only whole
numbers, only letters etc. to be accepted by a system.
Pseudocode example:
The following algorithm will accept only whole numbers and will reject any decimal numbers
INPUT Number
WHILE Number < > Number DIV 1 DO
OUTPUT “Wrong input, the value must be an integer”
INPUT Number
ENDWHILE
REPEAT
INPUT Number
IF Number < > Number DIV 1
THEN
OUTPUT “Wrong input, the value must be an integer”
ENDIF
UNTIL Number = Number DIV 1
//DIV operator gives integer division
iv. Presence check: It checks if data is present in a field or not. To be present the length of the field
must be more than 0 characters in length.
Pseudocode example:
// “” (two speech marks together) means empty string and for an empty string the length is 0
OUTPUT “Please enter your name: ”
INPUT Name
WHILE Name = “” DO
OUTPUT “No data given. Data must be given for this field”
INPUT Name
ENDWHILE
v. Format check: It checks if the data follows a particular pattern or not. For example date format
will be DD/MM/YYYY or student ID must follow the format of 0000-000 where 0 is a digit. If
the data given is not according to the pattern set by the program then values will be asked to be re-
Page 2 of 6
entered. (Format check algorithm will be covered with STRING manipulation topic)
vi. Check digit (used only for numbers): Checks if the final digit of a string of numbers is correct
or not. The final digit of a string of numbers is calculated from all the other digits based on a
particular algorithm. That final digit is the check digit. If the number has been input wrongly then
the check digit will not match and the system will generate an error message.
Verification: Verification is a method that checks if the data has been accurately / correctly copied /
given into a computer system. This may or may not be automated.
Double entry: For double entry the same data is entered twice, may be by the same operator or may be
by different operators. The computer system compares both entries and if they are different then outputs
an error message requesting for the data to be entered again. Entering password twice is an example of
double entry. Double entry verification is an automated checking by the program.
Pseudocode example:
//Take input of a password and ask the user to re-enter the same password. Allow the user to continue
until the same password is given. Display the number of times it took to enter the same password. Give
proper output and error message.
Page 3 of 6
OUTPUT “Password matched. It took ”, Count, “attempts to match”
PasswordMatched←TRUE //This will stop the WHILE loop
ELSE
OUTPUT “Password did not match” //This will continue the WHILE loop
ENDIF
ENDWHILE
// Flag variable is used as a signal in programming to let the program know that a certain condition has
met. A flag variable is a variable you define to have one value until some condition is true or false in
which case you change the variable's value. It is a variable you can use to control the flow of a function
or statement, allowing you to check for certain conditions while your function executing.
Screen / Visual check: 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 either checks the data on the screen against a paper
document that is being used as an input form or, confirms whether it is correct from their own
knowledge.
Practice questions
1. Which validation methods are being carried out by the following three pseudocode statements?
(ii) if gender = "male" and title = "Mr." then print "correct" ____________________________
2. A program requires the user to type in a user ID which must be in the form: AA000000 where A
stands for any letter, and 0 stands for any digit.
(a) Name two possible validation checks that could be applied to this user ID.
______________________________
______________________________
Page 4 of 6
(b) Name a validation check that could not be used on this occasion. Give a reason for your
choice.
3. A hospital holds records of its patients in a database. Four of the fields are:
• date of visit (dd/mm/yyyy)
• patient’s height (m)
• 8-digit patient ID
• contact telephone number
The presence check is one possible type of validation check on the data. For each field, give
another validation check that can be performed. Give an example of data which would fail your
named validation check and also an example of data which would pass the validation check.
A different validation check needs to be given for each field.
Patient’s height
Patient ID
Contact telephone
number
To verify if a check digit is correct the check digit has to be used as the last digit in the same algorithm
and after the entire process if the remainder becomes zero then the check digit will be regarded as correct
otherwise not.
Another example of check digit calculation is ISBN-10 which follows Modulo-11 method. The modulo-
11 method can have varying lengths of number which makes it suitable for many applications, such as
product codes or VINs. The check digit is calculated as follows:
1. the weighted value of each digit is first considered (The weighted values will be given)
2. Each digit in the number is then multiplied by its weighted value and the totals are added
together
3. The total is then divided by 11 (modulo 11) and the integer remainder is taken
4. If the remainder is zero (0) then this will be the check digit otherwise the remainder will be
subtracted from 11 to obtain the check digit. The remainder can be 10 as maximum.
5. After the subtraction from 11, if the check digit is calculated as 10 then it is represented by the
letter X.
6. For example 55/11, quotient is 5 and remainder is 0. So check digit will be 0. Another example,
59/11, quotient is 5 and remainder is 4. So the check digit will be 11-4 = 7. Another example,
43/11, quotient is 3 and remainder is 10. So the check digit will be 11-10 = 1. Another example,
45/11, quotient is 4 and remainder is 1. So the check digit will be 11-1 = 10, which will be
represented by the letter X.
To verify if a check digit is correct the check digit has to be used as the last digit in the same algorithm
and after the entire process if the remainder becomes zero then the check digit will be regarded as correct
otherwise not.
Usually in the question paper, the algorithm is given to perform check digit which must be followed to
answer properly. Check digit is always part of validation checking and not verification checking. Check
digit topic may appear in paper 1 (chapter 2) as well as in paper 2.
Page 6 of 6