Validations
Validations are added to an application so that only valid data is saved to your database – in other words, only keeping the signal and avoiding noise. For example, a user does not add their name in the age section, but uses a proper email ID format, and adds a proper cell phone number to validate the data on a portal, which is the basic requirement of the portal.
There are various ways and junctures at which we can set these validations in an application before the data gets persisted to the database. Mainly, there are four types of such validations:
- Database validations
- Controller-level validations
- Client-side validations:
- Model-level validations:
Let's look at each of these types one by one.
Database Validations
With database validations, we use database constraints or store procedures to check whether valid data is being stored. This is difficult to maintain since at the database level, changes are difficult to implement...