Data Validation Checks (Range, Length, Type, Presence)

Validation is an automatic computer check performed by software to ensure that data entered into a system is sensible, reasonable, and conforms to predefined rules before it is processed or committed to a database.


1. The Critical Distinction

Note: Exam Golden Rule: Validation DOES NOT check if data is factually correct. It only checks whether the data is acceptable according to the rules of the system. For example: If a student types their name as "Dvaid" instead of "David", a validation check will accept it because "Dvaid" satisfies presence, length, and character-type checks!


2. The Six Standard Validation Checks

Validation Check

Definition / Rule Tested

Concrete Example

Range Check

Verifies that a numerical or date value falls between an upper and lower boundary.

Month must satisfy $1 \le \text{Month} \le 12$. Exam score $0 \le \text{Mark} \le 100$.

Length Check

Verifies that a string contains either an exact number of characters or falls within minimum/maximum limits.

Password must be $\ge 8$ characters. PIN text must contain exactly 4 characters; a separate format check can require digits.

Type Check

Verifies that the value has the expected data type.

Age must be an integer. A STRING type alone does not restrict a surname to letters; a separate format rule is needed.

Presence Check

Verifies that a mandatory data field has not been left blank or empty.

National Insurance number or Email address field cannot be empty.

Format Check

Verifies that text conforms to a specific pattern or character mask.

Postal code matching LLN NLL (e.g. CB2 1TN). Date matching DD/MM/YYYY.

Check Digit

A calculated value appended to the end of a numerical code to detect transmission, transcription, or transposition errors.

Final digit of an ISBN-13 book code or EAN-13 barcode recalculated via modulo arithmetic.


3. Implementing Validation in Cambridge Pseudocode

Input validation loops ensure incorrect entries are rejected immediately and re-prompted:

DECLARE StudentAge : INTEGER

REPEAT
    OUTPUT "Enter student age (11 to 18): "
    INPUT StudentAge
    IF (StudentAge < 11) OR (StudentAge > 18) THEN
        OUTPUT "Invalid age! Must be between 11 and 18."
    ENDIF
UNTIL (StudentAge >= 11) AND (StudentAge <= 18)

OUTPUT "Valid age recorded: ", StudentAge

Notice that the REPEAT ... UNTIL loop checks the valid condition at the bottom to exit.

AI Socratic Tutor

All-Access
Sign in or create an account. AI Tutor is an All-Access benefit.
Sign Up

Need guidance? Ask a question or use the hint below.

AI Socratic Tutor is an All-Access Benefit

Unlock step-by-step Socratic hints, algorithm trace table walkthroughs, and error diagnostics for every Cambridge exercise.

You're chatting with an AI tutor, not a person. AI can make mistakes, so double-check its answers.

Exam-Style Check: Match Validation Checks to Data Input Scenarios

+25 XP

Match each validation check with its application scenario:

Instructions: Click a term on the left, then click its corresponding definition on the right.
Terms / Concepts
Descriptions / Definitions

All-Access Required

Interactive exercises for Module 2 and beyond require an active plan.