Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Basic Data Transformation ยท Lesson 9 of 9

Module Eight

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
9

MODULE 8: INTRODUCTION TO DATA VALIDATION AND QUALITY CHECKS

1. What You Will Learn

Welcome to the final module of Basic Data Transformation!

Imagine a school is preparing examination results for 500 students. Before publishing the results, the school discovers that some students have missing registration numbers, some scores are above 100, and some students have duplicate records.

These are examples of data quality problems.

Before using data for reports, analysis, or decision-making, we must check whether the information is correct and follows the required rules.

By the end of this module, you should be able to:

  • Explain data validation.
  • Identify incorrect and invalid information.
  • Create simple data validation rules.
  • Check whether data follows the correct format.
  • Use Python to validate information.
  • Use Excel and Google Sheets for data validation.
  • Perform basic data quality checks.

2. What Is Data Validation?

Data validation is the process of checking whether information follows specific rules before accepting or using it.

Think about a school registration form. The school may require:

  • Student name: Must not be empty.
  • Age: Must be between 10 and 25.
  • Registration number: Must be unique.
  • Examination score: Must be between 0 and 100.

If a student enters an examination score of 250, the system should identify it as invalid because the highest possible score is 100.

Example

Student Age Score Status
Ada1585Valid
Musa1770Valid
Tunde14150Invalid
Grace-560Invalid

Tunde's score is too high, while Grace's age is outside the school's allowed range.

3. Why Is Data Validation Important?

Incorrect data can produce incorrect reports and decisions.

Imagine a company wants to calculate how much money it received from customers in one month. If some payment records contain incorrect amounts, the financial report may be wrong.

Data validation helps to:

  1. Reduce errors in datasets.
  2. Improve the accuracy of reports.
  3. Prevent incorrect information from entering a system.
  4. Make data easier to analyse.
  5. Improve the quality of business and school records.
  6. Support better decision-making.

Remember: Good data produces more reliable results.

4. Common Data Validation Rules

A. Required Field Validation

A required field must not be empty.

For example, a school may require every student to provide a full name.

Student NameStatus
Aisha BelloValid
Daniel OkaforValid
EmptyInvalid

B. Data Type Validation

A data type rule checks whether information is stored in the correct format.

  • Age should be a number.
  • Student name should be text.
  • Registration date should be a date.
  • Payment amount should be numeric.

If someone enters "Fifteen" in a field that expects a number, the system may reject it.

C. Range Validation

Range validation checks whether a value falls within an allowed range.

Example: A school examination score must be between 0 and 100.

StudentScoreStatus
John75Valid
Mary100Valid
Peter120Invalid
David-10Invalid

D. Length Validation

Length validation checks how many characters a value contains.

For example, a school registration number may be required to contain exactly 8 characters.

  • CRM2026A: Valid
  • CRM26: Invalid
  • CRM2026AB: Invalid

The exact length depends on the organisation's rules.

E. Allowed Values Validation

Sometimes a field should only accept specific values.

For example, a school may allow only these examination statuses:

  • Pass
  • Fail
  • Pending

If a record contains "Excellent" in the examination status field, it does not follow the school's allowed values.

F. Uniqueness Validation

Uniqueness validation ensures that certain values do not appear more than once.

For example, every student should have a unique registration number.

StudentRegistration Number
AdaCRM001
MusaCRM002
TundeCRM003
GraceCRM002

Grace and Musa have the same registration number. This should be investigated using the school's official records.

G. Date Validation

Date validation checks whether dates follow an acceptable format and represent real calendar dates.

Examples of valid dates include:

  • 24/11/2026
  • 2026-11-24

However, 35/15/2026 is not a valid calendar date.

H. Consistency Validation

Consistency validation checks whether related information agrees.

For example, a student's date of birth indicates that the student is 15 years old, but the age field says 35. These two values do not agree and should be reviewed.

5. Introduction to Data Quality Checks

Data validation is one part of data quality management. Data quality checks help us determine whether a dataset is suitable for use.

Characteristic Meaning
AccuracyInformation correctly represents reality.
CompletenessImportant information is available.
ConsistencyRelated information agrees.
ValidityData follows required rules.
UniquenessUnwanted duplicates are avoided.
TimelinessInformation is up to date.

Imagine a company has a customer database. Some customers have missing phone numbers, some phone numbers appear twice, and some addresses are outdated. The company needs to check and improve its records before using them for customer communication.

6. Practical: Data Validation with Python

Python can help us check whether information follows specific rules.

Step 1: Create Student Records

students = [
    {"name": "Ada", "score": 85},
    {"name": "Musa", "score": 70},
    {"name": "Tunde", "score": 150},
    {"name": "Grace", "score": -5}
]

print(students)

Step 2: Check Examination Scores

The valid score range is 0 to 100.

for student in students:

    score = student["score"]

    if 0 <= score <= 100:
        print(student["name"], "has a valid score")

    else:
        print(student["name"], "has an invalid score")

What does this code do?

  • for checks each student one after another.
  • score collects the student's examination score.
  • if checks whether the score is between 0 and 100.
  • else displays a message when the score is outside the allowed range.

Expected Output

Ada has a valid score
Musa has a valid score
Tunde has an invalid score
Grace has an invalid score

7. Practical: Checking Required Fields

A student's name should not be empty. Let's create a simple validation rule.

students = [
    {"name": "Ada", "age": 15},
    {"name": "", "age": 16},
    {"name": "Musa", "age": 17}
]

for student in students:

    if student["name"].strip() == "":
        print("Student name is missing")

    else:
        print(student["name"], "is valid")

The strip() function removes unnecessary spaces at the beginning and end of text. A name containing only spaces will also be identified as missing.

8. Practical: Checking Age Validation

Let's assume a school accepts students between 10 and 25 years old.

ages = [15, 18, 30, -2, 12]

for age in ages:

    if 10 <= age <= 25:
        print(age, "is a valid age")

    else:
        print(age, "is an invalid age")

Expected Output

15 is a valid age
18 is a valid age
30 is an invalid age
-2 is an invalid age
12 is a valid age

9. Practical: Checking Duplicate Registration Numbers

Every student should have a unique registration number.

registration_numbers = [
    "CRM001",
    "CRM002",
    "CRM003",
    "CRM002"
]

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’