Professional Documents
Culture Documents
Lecture 2
Validation
• Validation is a process that checks that data is reasonable (side by side) before it is accepted by a computer system.
• Validation is automated meaning that a well designed algorithm should successfully decide whether or not data is
acceptable. These include:
• Range Checks
• Presence Checks
• Format Checks
• Type Checks
• Character Checks
• Check digit
• Length check
Range check
• A range check is used to ensure that numbers are only accepted into a
program if it falls within a certain acceptable range.
• Example - If a program asks for somebodies age then you might limit
entries to be between 13 and 100
Age = 0
OUTPUT "Please enter your age"
Age = INPUT()
WHILE Age < 13 OR Age > 100 DO
Presence check
• A Presence check is used to ensure that some data has been entered
OUTPUT "Please enter your name so that we can post your comment"
Name = INPUT()
WHILE Name = "" DO
OUTPUT "Sorry, You must enter a name before your post can be
published"
Name = INPUT()
END WHILE
Format check
• A format check is used to ensure that data entered matches a desired
pattern.
e.g. if a user is required to enter an email address then it should follow a set
pattern of "XXXXX" + @ + "XXXXX" + "." + "XXX" This would allow an
email address such as "example@gmail.com" to be accepted.
TYPE CHECK
• A Type check is used to ensure that the correct data type has been
entered. OUTPUT "Please enter your age"
• A Type check is used to ensure that an entered string does not contain any
unacceptable characters.