VJC Chapter 17 Data Validation and Verification
Uploaded by cheesemuffin · 10 December 2025
Preview
Text from the first pagesVJC/H2Computing/9569 Chapter 17 Data Validation and Verification Contents 1 Data validation and verification 1.1 Types of input error 1.2 Validation of data entry 1.2.1 Check digit 1.2.2 Method of calculating check digits 1.3 Verification of data entry 1.4 Workflow for data validation 2 Program testing 2.1 Syntax errors 2.2 Logical errors 2.3 Runtime errors 2.3.1 Exception Handling 2.4 Test data Annex 1 Datetime Annex 2 Timedelta Annex 3 Regular expression Syllabus Learning Outcomes 2.4 Data Validation and Program Testing Use data validation techniques and design test cases 2.4.1 Explain the difference between data validation and data verification. 2.4.2 Understand data validation techniques such as: – range check – format check – length check – presence check – check digit. 2.4.3 Identify, explain and correct syntax, logic, and runtime errors. 2.4.4 Design appropriate test cases using normal, abnormal and extreme data for testing and debugging programs. 1
VJC/H2Computing/9569 1 Data validation and verification Data integrity, which is the accuracy or validity of data, can never be guaranteed. However, the chances are improved if appropriate measures are taken when data originally enters a system or when it is transmitted from one system to another. 1.1 Types of input error Users keying in data could make transcription errors, a single incorrect character being entered, such as a wrong password or an invalid email address. For eg, a correct postal code 449035 could be wrongly entered as 449036 or the name Stanley might be wrongly entered as Stamley instead. Another type of input error is transposition error , where two digits are accidentally swapped. For eg, a correct NRIC S83123 45 B is wrongly entered as S83123 54 B . 1.2 Validation of data entry Data validation is a process of ensuring that the input data supplied to a system satisfies a set of rules such that it is sensible, complete, and within acceptable boundaries. Its purpose is to avoid data errors. It does not guarantee that data is accurate. For example, if the entry of a name is expected but the wrong name is entered, it will still be recognised as a name and therefore accepted as valid. Data validation techniques include: ● range check – Checks that a value falls within the specified range, e.g. The marks of the A level H2 Computing Paper 1 must fall within the specified range of 0 to 100 and not anything less than 0 or more than 100 marks. ● format check – Checks the data is in the right format, e.g. A date has to be dd/mm/yyyy. ● length check – Checks the data isn't too short or too long, e.g. A telephone number must have a length of 8 numbers. ● presence check – Checks that data has been entered into a field, e.g. ensure that an entry field is not left blank. ● check digit – An extra digit added to the end of a code number, which has been calculated from the digits of the code number. This ensures the code number has been entered properly. 2
VJC/H2Computing/9569 1.2.1 Check digit Code numbers, which could be made up of either digits only or a combination of digits and letters) such as customer number, employee number, or product number are often lengthy and prone to error when being keyed in. One way of detecting these errors is to add a check digit to the end of the code numbers. A check digit is a digit (or character) added to the end of a code number which has been calculated from the digits (or characters) of the code number. In this way the code number with its extra check digit is self-checking. Some examples of real-life data that use check digits are ● Singapore NRIC ● Singapore car plate registration number ● book ISBN ● credit card number (e.g. Luhn algorithm) 1.2.2 Method of calculating check digit The best-known method of calculating check digit is the modulo 11 system, which traps over 99% of all errors. The calculation of a check digit is shown below: 1. Each digit of the code number is assigned a 'weight'. The right-hand (least significant) digit is given a weight of 2, the next digit to the left 3, and so on. 2. Each digit is multiplied by its weight and the products are added together. 3. The sum of the products is divided by 11 and the remainder is obtained. 4. The remainder is subtracted from 11. 5. The result is divided again by 11 and the remainder (results mod 11) is the check digit. The only exception is that if the remainder is 10 and only a single check digit is allowed, the Roman number 'X' is used as a check digit. Example: ISBN check digit Digits: 3 9 2 8 4 4 4 0 4 Weight: 10 9 8 7 6 5 4 3 2 Results: 30 + 81 + 16 + 56 + 24 + 20 + 16 + 0 + 8 = 251 Calculate remainder: 251 / 11 = 22 Remainder 9 -> 11 - 9 = 2 Check digit 2 mod 11 = 2 The complete ISBN code number is 3928444042. 3
VJC/H2Computing/9569 Steps to verify if the check digit included is correct: ● The entire number is multiplied by the same weights that were used to calculate and the check digit itself is multiplied by 1. ● The results of the multiplication are added together. ● The number is correct if the sum is divisible by 11 with a remainder 0. In conclusion, the check digit should be a number that is appended to the string of code number, to make a sum of products that, when divided by 11, gives no remainder. Using the above ISBN code number to check: Digits: 3 9 2 8 4 4 4 0 4 2 Weight: 10 9 8 7 6 5 4 3 2 1 Results: 30 + 81 + 16 + 56 + 24 + 20 + 16 + 0 + 8 + 2 = 253 Calculate remainder: 253 / 11 = 23 Remainder 0 1.3 Verification of data entry Verification is the process of getting the user to confirm that the data entered was what was intended to be entered. Essentially, it is a way of preventing errors when data is copied from one medium to another. It does not check if the data makes sense or is within acceptable boundaries. It only checks that the data entered is identical to the original source. There are two methods of verification. Double entry is one method of verification. The process of entering data twice, with the second entry being compared with the first is to ensure that it is accurate. It is common in batch processing for a second data entry operator to key in a batch of data to verify it. Another example is when setting a password, a user would be asked to key in the password a second time to
Content continues in the PDF. Download PDF
Related notes
- NYJC 2026 Prelim P2Exam Papers · 2026
- NYJC 2026 Prelim P1Exam Papers · 2026
- DHS 2026 Y6 H2 Computing Prelim Paper 2_finalExam Papers · 2026
- ACJC 2026 JC2 Computing Prelim Paper 2 (Practical)Exam Papers · 2026
- 2026_NJC Prelim_Computing_P2.pdfExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P2_finalExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_markschemeExam Papers · 2026
- 2026_JPJC_Computing_Prelim_P1_finalExam Papers · 2026
- 2026 ACJC Prelim Computing Paper 2Exam Papers · 2026
- 2024 ACJC Computing PromoExam Papers · 2024
- 2023 ACJC Promo QPExam Papers · 2023
- 2022 ACJC Computing Promo Paper 2Exam Papers · 2022
- See all H2 Computing notes

