Data Validation
Validation is an automatic check to ensure that the data entered is sensible and feasible.
Validation cannot ensure data is accurate.
When programming, it is important that you include validation for data inputs. This stops
unexpected or abnormal data from crashing your program and prevents you from receiving
impossible garbage outputs.
Validation methods
Validation Method Description
Range check Checks the data falls between an acceptable upper
and lower value, within a set range
Type check Checks that the data entered is of an expected
type, e.g. text or a number
Length check Checks the number of characters meets
expectations, e.g. an 8 character password
Presence check Checks that the user has at least inputted
something, stopping them from accidentally
entering nothing
Check digit An extra digit added to a number which is
calculated from the other digits, this ensures the
rest of the number has been entered properly
Format Check A format check is used to ensure that the data
entered matches the desired pattern. e.g. if a user
is required to enter an email address then it should
follow a set pattern of "XXXXX" + @ +
"XXXXX" + "." + "XXX" This would allow an
email address such as "example@gmail.com" to be
accepted.
Character Check A Character check is used to ensure that an
entered string does not contain any unacceptable
characters.
An example scenario might be that a user needs to
choose a username. The username cannot contain
the ! or @ symbol as they are reserved for admin
usernames.
Verification
Verification is a way of preventing errors when data is copied from one medium to another.
Verification does not check if data makes sense or is within acceptable boundaries, it only
checks that the data entered is identical to the original source.
Verification methods
Verification Method Description
Double entry Data is entered twice and the computer checks
that they match up
Visual check The user manually reads and compares the newly
inputted data against the original source to ensure
they match
Test Data
Test data
Before performing a test, you need to decide what data you are going to include in your test
case. It is not normally possible to perform tests with every single possible piece of data. So,
instead, the developers will choose from a limited range of data such as:
● valid - the most obvious or common data that should work
● valid extreme - unusual, extreme or unexpected data, eg the highest and lowest (data
that tests the limits but that should work)
● invalid - data that should definitely fail
● invalid extreme - data that is at the edge of failure and is nearly acceptable
● Abnormal(erroneous) - data that is the wrong data type or not within the range
Sample Questions
1. A hospital is creating a database to store blood donors’ medical details. The fields in the
database include Health_number, Date_of_birth, Gender and Blood_group.
a. In the Blood_group field, the only data that can be entered is A, B, AB or O.State
whether each of the following blood groups is an example of abnormal or normal
data
- AB: …………………
- C: …………………...
- B: ………………….
- AO: …………………....
b. Each blood donor has a unique health number which uses a 10-digit number, for
example,9434765919.
Name the most appropriate validation check for the Health_number.
………………………………………………………………………………….
2. A teacher is creating a spreadsheet that will record the grades students achieved in
recent tests and compare the average grades of these tests with the students’ forecast
grades. The grading 4 the teacher is using awards 1 for the highest grade down to 10 for
the lowest. The teacher has created a validation rule on the grade entered. Give
examples of data used to test the validation rule. Your answers for abnormal test data
must be for a different reason in each case.
3. Data input by a customer at a car parking lot includes the day and the hour of arrival.
Identify one suitable validation check for each input and justify your choice.Your
validation checks must be different.
a. Day of arrival – validation check
b. Hour of arrival – validation check