Exception: JSONAPI::Exceptions::InvalidFieldValue

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#error_object_overrides

Instance Method Summary collapse

Methods inherited from Error

#create_error_object

Constructor Details

#initialize(field, value, error_object_overrides = {}) ⇒ InvalidFieldValue

Returns a new instance of InvalidFieldValue.



242
243
244
245
246
# File 'lib/jsonapi/exceptions.rb', line 242

def initialize(field, value, error_object_overrides = {})
  @field = field
  @value = value
  super(error_object_overrides)
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field.



240
241
242
# File 'lib/jsonapi/exceptions.rb', line 240

def field
  @field
end

#valueObject

Returns the value of attribute value.



240
241
242
# File 'lib/jsonapi/exceptions.rb', line 240

def value
  @value
end

Instance Method Details

#errorsObject



248
249
250
251
252
253
254
255
256
# File 'lib/jsonapi/exceptions.rb', line 248

def errors
  [create_error_object(code: JSONAPI::INVALID_FIELD_VALUE,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.invalid_field_value.title',
                                             default: 'Invalid field value'),
                       detail: I18n.translate('jsonapi-resources.exceptions.invalid_field_value.detail',
                                              default: "#{value} is not a valid value for #{field}.",
                                              value: value, field: field))]
end