chapter seven

7 Basic data validation

 

This chapter covers

  • The importance of validating data at system boundaries
  • Validating data using JSON schema language
  • Integrating data validation into an existing code base
  • Getting detailed information about data validation failures

7.1 A solemn gift

At first sight, it may seem that embracing Data-Oriented programming means accessing data without validating it, and engaging in wishful thinking that data is always valid.

In fact, data validation is not only possible but recommended when we follow Data-Oriented principles. This chapter illustrates how to validate data when data is represented with generic data structures. This chapter focuses on data validation occurring at the boundaries of the system while in Part 3, we will deal with validating data as it flows through the system.

This chapter is a deep dive into the fourth principle of Data-Oriented Programming:

[Note]  Note

Principle #4: Separate data schema and data representation.

7.2 Data validation in DOP

Theo has rescheduled his meetings, still not sure if he’s made a big mistake giving DOP a second chance.

[Warning]  Warning

The reason why Theo rescheduled his meetings is explained in the opener for Part 2. Please take a moment to read the opener if you missed it.

JOE: What aspect of Object-Oriented programming do you think you will miss the most in your big project?

THEO: Data validation.

JOE: Can you elaborate a bit?

7.3 JSON schema in a nutshell

7.4 Schema flexibility and strictness

7.5 Schema composition

7.6 Details about data validation failures

7.7 Summary