Computer Science LearnITWithMrC ⛯ Year 7 Year 8 Year 9 GCSE
Responsive image

Lesson Video


Lesson Tasks

  • Watch the Lesson video
    Make notes on your notes sheet.
  • Read the lesson notes
    Make notes on your notes sheet.
  • Complete the learning activities
    Make any notes on your notes sheet.
  • Check the Learning outcomes
    Update your learning objectives

What do I need to Learn?

I need to learn how to explain what data validation is.

Key Terms

validation validation checks Verification Type check Format check Length check Presence check Range check Lookup check Check digit

Data Validation - Learning Activities

Database validation is a process where the data entered in the database is checked to make sure that it is correct. The purpose of validation is to make sure that data is logical, rational, complete and within acceptable limits.

There are a range of validation methods like range check, type check etc. (see table in notes for more details)

A range check is probably the simplest validation method to understand. We give the user a range of values that are valid to enter then check they have entered a value in that range.

For example we could ask the user to enter a number between 1 and 10. Our validation routine would then check if the value entered was in that range. If the user entered say the number 11 our code should declare the value 'invalid' and ask the user to enter another value

Range Check – generally used when working with data which contains numbers, currency or date and time.

A range check lets you set appropriate limits:

Boundary Description Validation
Upper limit The maximum value is 10. <=10
Lower limit The minimum value is 1. >=1
A range Number entered must be less than or equal to 10 but greater than or equal to 1. >=1 and <=10

Data Validation in practice

I have coded the simple example above using a function called data validation. Run the code and check that it works.

Coding activity

Task 1: Range Check

Write some code that asks the uset to enter their age and checks if they are older than 11 and younger than 19.

Task 2: Length check

Write some code that asks the user to enter their phone number and checks if it is 12 digits or less.

Task 3: Verification

Write some code that asks the user to enter their password twice and checks that both entries are the same

Learning Outcomes

  • I can explain what validation and verification is.
  • I can create code to validate some data.
  • I can create code to validate and verify data
    using a range of different methods