Validation and Error Handling

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

Validation and error

handling

Validation
In order for data to be useful in a
computer system it first has to be
entered into the chosen system.
Many errors occur at the point of entry
into the system.
Validation is a check that is performed
on the entered data that tries to
prevent the entry of data that does not
conform to pre-set rules.

Validation continued..
It is possible to create many rules,
however they will not stop incorrect
data being entered, they will just
ensure that the data that is entered
is: Sensible
Reasonable
Within acceptable boundaries
Complete

Validation checks
The checks that can be applied fall into
several categories: Range
Type
Presence
Length
Lookup
Picture
Check digit

Range checks
A Range Check sets the upper and
lower boundaries for the data being
entered.
E.g. in this school you would be in
years 7 to 13.
A lower boundary would be 7 and the
upper boundary would be 13.

Presence checks
Not all items will need to be completed in a
database, for example some people may not
have, or may not wish to provide a mobile
phone number.
Other fields are required for example your
name and address in a delivery companies
records are essential but your email
address is not.
Presence checks will not allow you to leave
certain fields empty.

Type checks
Type checks make sure that the data
being entered is of the correct type.
E.g. Numeric, String, Boolean,
Date/Time.
This will prevent things like text being
entered into a numeric or date/time
field.

Length checks
This type of validation ensures that the
data that has been entered is of an
acceptable length.
A single character has a length of 1.
ICT has a length of 3 and hello has a
length of 5.
This makes sure that an entry is not
too short or too long for the field.

Lookup checks
This is where data is cross referenced
against a list to make sure that it is
valid and acceptable.
For example post codes can be
checked against a list and if there is
more than one house for the code a
choice can be given.
Lookup validation is not a search, it is
a comparison against known data.

Picture checks
This is also referred to as the format check. Some
data might be a combination of numbers and letters.
This will mean you can not apply the type check.
However the location of the numbers and letters
within the data might be in the same place every
time.
For example RT678H, FD234R, GQ836F.
First two letters, followed by three numbers finally
one more letter.
This would allow the format check of LLNNNL to be
applied to the field. Where L is a letter and N a
number.

Check digit
A check digit is calculated from a set of
numbers and then added to them.
This is commonly used to check numbers
that are being sent to ensure that they are
not corrupted during transmission.
Before being sent the check digit is
calculated and added to the number. Before
processing at the far end the number is
rechecked to ensure that it is correct.

Example check digit


All sorts of numbers are checked using
check digits from credit card numbers
to account numbers and serial
numbers.
The example that we are going to look
at is the ISBN number found on all
published books. This number uniquely
identifies every book in the world. A
ten digit ISBN number is calculated
using Modulus 11 as shown on the

You might also like