lib/volt/models/validations.rb
def errors(marked_only = false)
      errors = {}

      # Merge into errors, combining any error arrays
      merge = proc do |new_errors|
        errors.merge!(new_errors) do |key, new_val, old_val|
          new_val + old_val
        end
      end

      # Get the previous model from the buffer
      save_to = options[:save_to]
      if save_to && save_to.is_a?(Volt::Model)
        old_model = save_to
      else
        old_model = nil
      end

      errors = run_validations(errors, merge, marked_only, old_model)

      # See if any server errors are in place and merge them in if they are
      if Volt.client?
        errors = merge.call(server_errors.to_h)
      end

      errors = run_custom_validations(errors, merge, old_model)

      errors
    end
# TODO: Errors is being called for any validation change.  We should have errors return a
# hash like object that only calls the validation for each one.
Errors is being called for any validation change.  We should have errors return a
hash like object that only calls the validation for each one.
Errors is being called for any validation change . We should have errors return a hash like object that only calls the validation for each one .
def errors(marked_only = false)
      errors = {}
      merge = proc do |new_errors|
        errors.merge!(new_errors) do |key, new_val, old_val|
          new_val + old_val
        end
      end
      save_to = options[:save_to]
      if save_to && save_to.is_a?(Volt::Model)
        old_model = save_to
      else
        old_model = nil
      end
      errors = run_validations(errors, merge, marked_only, old_model)
      if Volt.client?
        errors = merge.call(server_errors.to_h)
      end
      errors = run_custom_validations(errors, merge, old_model)
      errors
    end
def errors ( marked_only = false ) errors = { } merge = proc do | new_errors | errors . merge! ( new_errors ) do | key , new_val , old_val | new_val + old_val end end save_to = options [ :save_to ] if save_to && save_to . is_a? ( Volt :: Model ) old_model = save_to else old_model = nil end errors = run_validations ( errors , merge , marked_only , old_model ) if Volt . client? errors = merge . call ( server_errors . to_h ) end errors = run_custom_validations ( errors , merge , old_model ) errors end
TODO: Errors is being called for any validation change.
TODO : Errors is being called for any validation change .
# Merge into errors, combining any error arrays # Get the previous model from the buffer # See if any server errors are in place and merge them in if they are
marked_only