Validations
This section is based on Granite's README
Errors
All database errors are added to the errors
array used by Granite::ORM::Validators with the symbol ':base'
Custom validations
If you require to add more data validation to your model, you can do so by using the validate
method.
validate
method can be used to validate the whole object or an attribute of the object. These validations are not automatically checked when you save, to do so you need to run the .valid?
method.
Failing the validation does not prevent the object from being persisted (saved).
To validate whole object
Example:
To validate a field in an object
Example:
Last updated