class Suretax::Concerns::Validatable::Error
Attributes
attribute[RW]
message[RW]
value[RW]
Public Class Methods
new(attribute, value)
click to toggle source
# File lib/suretax/concerns/validatable.rb, line 25 def initialize(attribute, value) self.value = value self.attribute = attribute self.message = "Invalid #{attribute}: #{reason}" end
Private Instance Methods
format_error(value)
click to toggle source
# File lib/suretax/concerns/validatable.rb, line 41 def format_error(value) if value.nil? "nil" elsif value.is_a?(String) && value.empty? %('') else value end end
format_nested_errors(value)
click to toggle source
# File lib/suretax/concerns/validatable.rb, line 37 def format_nested_errors(value) value.map { |obj| obj.errors.messages.join(", ") } end
nested_errors?()
click to toggle source
# File lib/suretax/concerns/validatable.rb, line 51 def nested_errors? value.respond_to?(:each) && value.all? { |obj| obj.respond_to?(:errors) } end
reason()
click to toggle source
# File lib/suretax/concerns/validatable.rb, line 33 def reason nested_errors? ? format_nested_errors(value) : format_error(value) end