Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jsonapi/rails/serializable_active_model_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def initialize(exposures)

def as_jsonapi
error_keys.flat_map do |key|
@errors.full_messages_for(key).map do |message|
@errors.messages[key].map do |message|
SerializableActiveModelError.new(field: key, message: message,
pointer: @reverse_mapping[key])
.as_jsonapi
Expand Down
8 changes: 4 additions & 4 deletions spec/render_jsonapi_errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
{
'errors' => [
{
'detail' => "Name #{I18n.t('errors.messages.blank')}",
'detail' => "#{I18n.t('errors.messages.blank')}",
'title' => 'Invalid name',
'source' => { 'pointer' => '/data/attributes/name' }
},
{
'detail' => 'Email must be a valid email',
'detail' => 'must be a valid email',
'title' => 'Invalid email',
'source' => { 'pointer' => '/data/attributes/email' }
}
Expand Down Expand Up @@ -64,12 +64,12 @@ def jsonapi_pointers
def create
errors = [
{
detail: "Name #{I18n.t('errors.messages.blank')}",
detail: "#{I18n.t('errors.messages.blank')}",
title: 'Invalid name',
source: { pointer: '/data/attributes/name' }
},
{
detail: 'Email must be a valid email',
detail: 'must be a valid email',
title: 'Invalid email',
source: { pointer: '/data/attributes/email' }
}
Expand Down