Exception: JSONAPI::Exceptions::InvalidFieldValue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, value) ⇒ InvalidFieldValue

Returns a new instance of InvalidFieldValue.


180
181
182
183
# File 'lib/jsonapi/exceptions.rb', line 180

def initialize(field, value)
  @field = field
  @value = value
end

Instance Attribute Details

#fieldObject

Returns the value of attribute field


179
180
181
# File 'lib/jsonapi/exceptions.rb', line 179

def field
  @field
end

#valueObject

Returns the value of attribute value


179
180
181
# File 'lib/jsonapi/exceptions.rb', line 179

def value
  @value
end

Instance Method Details

#errorsObject


185
186
187
188
189
190
191
192
193
# File 'lib/jsonapi/exceptions.rb', line 185

def errors
  [JSONAPI::Error.new(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