Class: SmartCore::Validator::ErrorsController::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_core/validator/errors_controller/base.rb

Direct Known Subclasses

ErrorPerAttribute, ManyErrorsPerAttribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



6
7
8
# File 'lib/smart_core/validator/errors_controller/base.rb', line 6

def initialize
  @errors = SmartCore::Validator::Errors.new
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



4
5
6
# File 'lib/smart_core/validator/errors_controller/base.rb', line 4

def errors
  @errors
end

Instance Method Details

#apply_data_to_errors!Object



# File 'lib/smart_core/validator/errors_controller/base.rb', line 26

#error_will_be_skipped?Object



# File 'lib/smart_core/validator/errors_controller/base.rb', line 26

#process_rule!(result) ⇒ Object



16
17
18
19
20
# File 'lib/smart_core/validator/errors_controller/base.rb', line 16

def process_rule!(result)
  return if result == nil

  apply_data_to_errors!(result.attr_path, result.code)
end

#process_smart_schema_result!(result) ⇒ Object



10
11
12
13
14
# File 'lib/smart_core/validator/errors_controller/base.rb', line 10

def process_smart_schema_result!(result)
  result.errors.each do |attr_path, error_codes|
    apply_data_to_errors!(attr_path, *error_codes)
  end
end

#validation_fails?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/smart_core/validator/errors_controller/base.rb', line 22

def validation_fails?
  @validation_fails ||= errors.any?
end