What Is Data Validation
What Is Data Validation
Data validation is the process of verifying and validating data that is collected
before it is used. Any type of data handling task, whether it is gathering data,
analyzing it, or structuring it for presentation, must include data validation to
ensure accurate results. Sometimes it can be tempting to skip validation since it
takes time. However, it is an essential step toward garnering the best results
possible.
Validation scripts
Within the validation script, you can use the following features:
Aggregate functions
Validation functions
Multi-line boolean expressions
Collections
Closures
Aggregate functions
Function Result
Validation functions
To make the validation script more readable, there are many packaged
validation functions. The built-in validation functions not only handle the
validation, but they also provide a way to produce meaningful error messages. For
more advanced functions, you need a closure, more information:
General functions
Error messages
String functions
Number functions
Date conversion functions
Date functions
The validation script of a validation rule may consist of multiple boolean
expressions. To increase legibility, you can use specific constructs.
Using the constructs makes your rule a little more verbose, but more readable in
most cases.
Constructions
Expression Purpose
Collections
NoteIf a reference points to a value that doesn't exist, the rule will crash. For
example, retrieving the fifth value of a list that only contains four values causes a
crash.
Reference Result
mylist[1] The second element from the list mylist. The number is the index of the value you
the list.
mylist.get(1) The second element from the list my list. It is very similar to the example above.
mylist?.get(1) The second element from the list. However, this syntax is null-safe. ?. is the null-s
You cannot combine the ?. with the [ ... ] notation. This means that if the reference
present, the result is null, whereas the expression without the question mark fails t
TYPE CHECK
Data comes in different types. One type of data is numerical data — like years,
age, grades or postal codes. Though all of these are numbers, they can be either
integers or floats. For example, a year can’t be 2010.14 because years must be
integers. On the other hand, grades can be either an integer (99) or a float (90.5).
Another type of data is text data — names, addresses or emails, for instance.
FORMAT CHECK
Format checking validates the data’s structure. For example, birthdays have a
specific format (say, YYYY-MM-DD). Having the data in this format is essential
for the project’s next steps, so checking that your data has the correct structure is
vital. When you’re validating the data structure, you should have a clear
understanding of the correct structure in order to make the validation process
consistent and straightforward.
CORRECTNESS CHECK
Sometimes the data may be in the correct format but may need to be corrected. For
example, a birthday entry may be 1990-13-06. Although the format is valid, there’s
no month 13. This step in the validation ensures that your values are logical and
meaningful. Another example is checking if a postal code or a phone number is
valid. Sometimes this is referred to as the range check.