I learned about validation, so As an output, we will introduce the features and usage of validation.
What is validation? "When a parameter is sent from the view to the server side through the input form, it is a function to verify whether it is a normal value".
The main use case is to verify the contents of the form and check it. If not, an error is displayed.
For example, if you require the user to enter the phone number.
validates :e-mail, presence: true
This will allow you to see the error if no e-mail has been entered.
If you want to check if the value is empty as I raised earlier, You can use validates_presence_of for further simplification.
Example
validates_presence_of :e-mail:
Now you can return an error if no e-mail has been entered.
Recommended Posts