module OnForm::Validations

Public Class Methods

included(base) click to toggle source
# File lib/on_form/validations.rb, line 3
def self.included(base)
  base.validate :run_backing_model_validations
end

Public Instance Methods

form_errors?() click to toggle source
# File lib/on_form/validations.rb, line 11
def form_errors?
  !!(@_form_validation_errors || child_form_errors?)
end
invalid?() click to toggle source
# File lib/on_form/validations.rb, line 7
def invalid?
  !valid?
end

Private Instance Methods

child_form_errors?() click to toggle source
# File lib/on_form/validations.rb, line 32
def child_form_errors?
  collection_wrappers.values.map(&:form_errors?).any?
end
run_backing_model_validations() click to toggle source
# File lib/on_form/validations.rb, line 16
def run_backing_model_validations
  backing_model_instances.each { |backing_model| backing_model.valid? }
end
run_child_form_validations!() click to toggle source
# File lib/on_form/validations.rb, line 28
def run_child_form_validations!
  collection_wrappers.each_value {|collection| collection.validate_forms(self) }
end
run_validations!() click to toggle source
Calls superclass method
# File lib/on_form/validations.rb, line 20
def run_validations!
  super
  @_form_validation_errors = !errors.empty?
  collect_errors_from_backing_model_instances
  run_child_form_validations!
  errors.empty?
end