Use Cases
In the previous chapter, we saw how to validate models against many rules/constraints.
Yet, in your use cases, you may want to control when to validate these models.
Simple Scenario#
This scenario occurs when you are manipulating only one model in your use case.
For instance, let's say you want to save a User instance and validate its data:
Here the save method from the DAO validates the User instance. No rocket science!
"Complex" Scenario#
Now let's say users have an optional profile picture.
You have to verify that:
- The
Userinstance is valid. - If it exists, the storable
ProfilePictureis valid. - The instructions' order will not leave the data in a dirty state.