Data Validation

entering realistic data

Every student in a school is assigned an id number.

When searching for a student in a database, a valid id must be entered. Valid ids:

  • have a format of "s01234".
  • the first 2 characters are always the string "s0"
  • the final 4 characters are always integers.
  • for example, other valid student IDs are s05443, s04323, s05434. An invalid ID would be x04343 or s@1213
  • hence, the length of an id is always 6 characters.

Any id that does not follow these rules is invalid.

Enter some valid and invalid student ids and see what happens:

 

Can you see what is happening?

Code has been written to check the data entry. The code asks are you valid? and if the input is not valid an error message appears and the user has to try again.

These methods of checking valid or invalid data entry are known as validaiton checks.

Validation checks

check   description
length check   to check that the length of the input string is valid.
presence check   to check that there is any data present when input.
format check   to check that the data is in the correct format eg 12:34:00 for time data, not 12;34;00 which is invalid.
range check   to check that numerical data, eg somebody's age, is within a certain range eg 13-19 for a teenager.
type check   to check that the data type is correct, eg we cannot enter hello (a string) when we should enter someone's age (an integer).

Activity

Verification check

Verification checks are different from validation checks.

Validation checks make sure that the correct kind of data is being entered.

Verification checks make sure that the correct data is being entered.

For example, huge businesses store massive amounts of data. If incorrect data is entered into systems, big problems can occur. Imagine if a banker entered $1,000,000 instead of $1,000 into a system! Both numbers might be valid, but only one is correct.

Here are some common types of verification checks:

  1. An employee double checks her data entry before submitting it into the system.
  2. Two people enter the same data into the system. The system compares the two sets of data and indicates if there are any differences.
  3. One worker enters the data, the other workers double checks the data entry.