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 ScenarioThis 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" ScenarioNow let's say users have an optional profile picture.
You have to verify that:
- The
User
instance is valid. - If it exists, the storable
ProfilePicture
is valid. - The instructions' order will not leave the data in a dirty state.