Data Validation Overview. V1
Validation first, followed by verification.
- Validation – does the data match the template?
Example: The date template could be “yyyy-MM-dd” - Verification – the data does match the template but is it valid?
Example: “2026-14-13” matches the template but is not valid because no year has 14 months.
We validate in three ways.
- Object validation.
- String validation – always start with trim( )
- Number validation – always start with trim( ) because data from a form starts off as a String.
Forms – GUIs – Using JFrameForm
All forms, like the one below, only accept text (String) into the open white fields. Therefore numbers (integers, doubles, dates, times) start off as String first and are then parsed to a number using “Integer.parseInt” , “Double.parseDouble”, “LocalDate.parse”, “LocalTime.parse” etc
Missing data, normal data, extreme data and abnormal data
We must trap (validate) the errors (or omissions) that a person makes when filling in an online form. Our code must only accept normal data.
- Missing data: Name:
- Normal data: Name = Steve Eilertsen.
- Extreme data: Name = Steve Eilertsennnnnnnnnnnnnnnnnnnnnnnnnnnn.
- Abnormal data: Name = S$t&44 &e9*
Object validation
- Unwanted negative numbers and decimal values.
- File not found.
- Empty date.
- Empty time.
- Numbers with unwanted letters.
String Validation
- String is too long.
- String is null.
- String has no length (but is not null).
- String has strange characters.
Numbers
Validation
Using “try . . . catch with Integer.parseInt” or Double.parseDouble is an easy way to determine if a number is in a valid number format. If the format is acceptable then we can do further verification. See below.
- Numbers must be in an acceptable range
- Numbers cannot come from a String that is null
Verification
Once data has been validated it must be verified
Example: The date: 2026-14-17. This date will pass a validation test but not a verification test because there are not 14 months in a year.
With regard to the data validation task for grade 11 and grade 12