Validation & Verification

When devloping your programs, it is important that you consider whether any inputs from the user will break your program. Making a program that considers plans for this in advance is known as defensive design and will make your program robust.

GCSE computer science

Using techniques like validation and verification help to make your program more robust as they prevent incorrect data from entering the system.

The phrase commonly used with this is “Garbage in, Garbage out”.


Verification is useful for user input when you want to check that what your user is inputting is what they wanted to input. For example, when entering a new password a website will often ask the user to input it twice to ensure that they didn’t make a spelling error.

password1 = INPUT
password2 = INPUT

WHILE password1 <> password2 DO
OUTPUT "passwords do not match "
password1 = INPUT
password2 = INPUT



Validation is applying certain rules to the data that your user inputs into the system. By adding validation to your code, it prevents the program from crashing when incorrect data is entered.

There are a number of different types of validation that can be used within your programs:

  • Type Checks
  • Length Checks
  • Presence Checks
  • Format Checks
  • Range Checks

Each of these types of checks can be combined together to make sure that your user is entering correct data into the system.

When a user enters data incorrectly, it is usual for a program to prevent them from moving forward until the data is correct. Knowing that we want our user to keep entering data until they get it right indicates that we want to use a type of loop that will keep repeating until the condition is met. In this case, either a WHILE or REPEAT UNTIL loop is best.

age = INPUT

WHILE age.Type <> Integer DO

    OUTPUT "Age nust be a whole number "

    age = INPUT

For more information on iteration (loops), click here.

Looking for More?

Sign in to access the following extras on this page for members:

Lesson Plan Notes



A Level Content

Looking for something else? Check back soon as new resources are added every week!

Not a member yet? Sign Up or Log In below