Published by Patrick Mutisya · 14 days ago
Know and understand validation routines including range check, character check, length check, type check, format check, presence check, and check digit.
Data validation is the process of ensuring that the data entered into a system meets the required criteria before it is processed or stored. Validation is a key activity in the Implementation and Testing phases of the systems life cycle.
Ensures that a numeric value falls within a predefined minimum and maximum.
Example: Age must be between 0 and 120.
Verifies that a character belongs to an allowed set (e.g., letters only, digits only).
Example: A country code must consist of uppercase letters A–Z.
Confirms that the number of characters entered matches the required length.
Example: A UK post‑code must be 5–7 characters long.
Ensures that the data type entered matches the expected type (numeric, alphabetic, alphanumeric, date, etc.).
Example: A field for “Quantity” must be numeric.
Validates that the data follows a specific pattern, often using regular expressions.
Example: A telephone number must match the pattern +44 0 1234 567890.
Ensures that a required field is not left blank.
Example: The “Email Address” field must contain a value before the form can be submitted.
A mathematical digit added to a number to help detect errors in data entry or transmission. The check digit is calculated using a specific algorithm (e.g., Mod‑10, Mod‑11).
Example: ISBN‑13 uses a check digit calculated as:
\$\$
\text{Check Digit} = (10 - ( \sum{i=1}^{12} wi \times d_i \bmod 10 )) \bmod 10
\$\$
where \$wi\$ is 1 for odd positions and 3 for even positions, and \$di\$ are the first 12 digits of the ISBN.
| Check Type | Purpose | Typical Example | Common Implementation |
|---|---|---|---|
| Range Check | Value within minimum and maximum limits | Age 0–120 | if (value >= min && value <= max) … |
| Character Check | Allowed characters only | Country code A–Z | regex /^[A-Z]+$/ |
| Length Check | Exact or range of characters | Post‑code 5–7 characters | if (len >= 5 && len <= 7) … |
| Type Check | Correct data type (numeric, date, etc.) | Quantity numeric | isNaN(value) === false |
| Format Check | Specific pattern required | Phone +44 0 1234 567890 | regex /^\+44\s0\s\d{4}\s\d{6}$/ |
| Presence Check | Field must not be empty | Email address required | if (value.trim() !== '') … |
| Check Digit | Detect entry errors using algorithm | ISBN‑13 validation | Calculate using Mod‑10 algorithm |