Method: LedgerSync::Type::ReferenceMany#error_message

Defined in:
lib/ledger_sync/type/reference_many.rb

#error_message(attribute:, resource:, value:) ⇒ Object



15
16
17
18
19
20
# File 'lib/ledger_sync/type/reference_many.rb', line 15

def error_message(attribute:, resource:, value:)
  return super unless value.is_a?(Array)

  invalid_classes = value.reject { |e| e.is_a?(resource_class) }.map(&:class)
  "Attribute #{attribute.name} for #{resource.class.name} should be an array of #{resource_class.name}.  Given array containing: #{invalid_classes.join(', ')}"
end