Introduction
In this era of information explosion, the correctness of data is crucially important. We need to ensure that the data passed in by the client is in the format we expect. For example, we expect the cooking time
variable to be a data type integer with a value of 30, but the client could pass in a string data type, with value = "thirty minutes"
. They mean the same thing, and both are understandable to human beings but the system won't be able to interpret them. In this chapter, we will learn about data validation, making sure the system only takes valid data. The marshmallow package not only helps us to verify the client's data but also to verify the data that we send back. This ensures data integrity in both directions, which will greatly improve the quality of the system.
In this chapter, we will focus on doing three essential things: first, we will modify the User
class and add in the API verification. This is mainly to show the basic functions...