module ActiveModel::Validations::Callbacks::ClassMethods

def before_validation(*args, &block)

person.name # => "bob"
person.valid? # => true
person.name = ' bob '
person = Person.new

end
end
name.strip!
def remove_whitespaces
private

before_validation :remove_whitespaces

validates_length_of :name, maximum: 6

attr_accessor :name

include ActiveModel::Validations::Callbacks
include ActiveModel::Validations
class Person

Defines a callback that will get called right before validation.
def before_validation(*args, &block)
  options = args.extract_options!
  set_options_for_callback(options)
  set_callback(:validation, :before, *args, options, &block)
end