validates!(*attributes)
Instance Public methods
This method is used to define validations that cannot be corrected by end
users and are considered exceptional. So each validator defined with bang
or :strict
option set to true
will always raise
ActiveModel::StrictValidationFailed
instead of adding error
when validation fails. See validates
for more information
about the validation itself.
1 2 3 4 5 6 7 8 9 10 11 | class Person include ActiveModel::Validations attr_accessor :name validates! :name , presence: true end person = Person. new person.name = '' person.valid? # => ActiveModel::StrictValidationFailed: Name can't be blank |
Please login to continue.