ComputingRevision.net

3.2.3-4 Data Validation

Data validation checks if data is reasonable, but cannot check if it is correct.

There are eight types of input validation you need to know.

Data Type Check

a funnel filtering numbers

Ensures data is of a specific type (e.g. an integer).

Example: A year must only contain an integer (e.g. 1975).

Format Check

Format check

Data must match a specific combination of character types.

Example: A national insurance number must be in the NN LL LL LL N (where N is a number and L is a letter) format (e.g. CR 83 92 10 Z).

Input Mask

Input mask

Spaces are provided for specific characters to be entered.

Example: A Credit card input field would be split into four blocks of four numbers (e.g. 0000 0000 0000 0000).

Length Check

Illustration of a tape measure

There is a minimum and/or maximum number of characters required.

Example: A password must be at least 10 characters.

Limited choice

Illustration of radio buttons

Data can only be selected from pre-defined options (users cannot type their own data).

Example: An online clothes shop only allows users to select "S", "M", "L", or "XL".

Lookup

Illustration of two eyes looking upwards

A check that what the user enters exactly matches one in an existing list.

Example: Typing a product stock code into a database and comparing it to an existing product code.

Presence Check

A required form field

Checking if an input box has something entered into it.

Example: The "Full Name" field must not be empty; leaving it blank produces an on-screen alert.

Range Check

Illustration of a speedometer

Checking if a value is between two numbers.

Age entry requires a value between 11 and 18; entering "9" or "21" triggers a warning.

Quick Quiz

Click the purple circle to select your answer

Which validation method checks that the number of characters entered is not too short or too long?

Length check
Presence check
Format check
Range check