module ActiveRecord::Validations

def perform_validations(options={}) # :nodoc:

:nodoc:
def perform_validations(options={}) # :nodoc:
  options[:validate] == false || valid?(options[:context])
end

def save(options={})

module is mixed in, which it is by default.
The regular Base#save method is replaced with this when the validations
The validation process on save can be skipped by passing validate: false.
def save(options={})
  perform_validations(options) ? super : false
end

def save!(options={})

exception instead of returning +false+ if the record is not valid.
Attempts to save the record just like Base#save but will raise a +RecordInvalid+
def save!(options={})
  perform_validations(options) ? super : raise(RecordInvalid.new(self))
end

def valid?(context = nil)

some :on option will only run in the specified context.
Validations with no :on option will run no matter the context. Validations with

new_record? is +true+, and to :update if it is not.
If the argument is +false+ (default is +nil+), the context is set to :create if

no errors are found, +false+ otherwise.
Runs all the validations within the specified context. Returns +true+ if
def valid?(context = nil)
  context ||= (new_record? ? :create : :update)
  output = super(context)
  errors.empty? && output
end