Validating input data in flash
You can even create your own validation helpers and reuse them in several different models.
For example, you may want to confirm an email address or a password.Active Record offers many pre-defined validation helpers that you can use directly inside your class definitions. Every time a validation fails, an error message is added to the object’s collection, and this message is associated with the field being validated.Each helper accepts an arbitrary number of attribute names, so with a single line of code you can add the same kind of validation to several attributes. Let’s take a look at each one of the available helpers.The block receives the model, the attribute’s name and the attribute’s value.You can do anything you like to check for valid data within the block.