822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
|
# File 'lib/jsonapi/resource.rb', line 822
def verify_key(key, context = nil)
key_type = resource_key_type
case key_type
when :integer
return if key.nil?
Integer(key)
when :string
return if key.nil?
if key.to_s.include?(',')
raise JSONAPI::Exceptions::InvalidFieldValue.new(:id, key)
else
key
end
when :uuid
return if key.nil?
if key.to_s.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/)
key
else
raise JSONAPI::Exceptions::InvalidFieldValue.new(:id, key)
end
else
key_type.call(key, context)
end
rescue
raise JSONAPI::Exceptions::InvalidFieldValue.new(:id, key)
end
|