Commit 16c82a4
Changed files (2)
lib
scim
kit
spec
scim
kit
lib/scim/kit/v2/attribute_type.rb
@@ -102,12 +102,27 @@ module Scim
def valid?(value)
if complex?
- return false unless value.is_a?(Hash)
- value.keys.each do |key|
- attribute = attributes.find { |x| x.name.to_s.underscore == key.to_s.underscore }
- return false unless attribute.valid?(value[key])
+
+ if multi_valued
+ return false unless value.respond_to?(:each)
+
+ value.each do |item|
+ return false unless item.is_a?(Hash)
+
+ item.keys.each do |key|
+ attribute = attributes.find { |x| x.name.to_s.underscore == key.to_s.underscore }
+ return false unless attribute.valid?(item[key])
+ end
+ end
+ else
+ return false unless value.is_a?(Hash)
+
+ value.keys.each do |key|
+ attribute = attributes.find { |x| x.name.to_s.underscore == key.to_s.underscore }
+ return false unless attribute.valid?(value[key])
+ end
+ true
end
- true
else
if multi_valued
return false unless value.respond_to?(:each)
spec/scim/kit/v2/attribute_type_spec.rb
@@ -140,6 +140,7 @@ RSpec.describe Scim::Kit::V2::AttributeType do
end
specify { expect(subject).to be_valid([value: email, primary: true]) }
+ specify { expect(subject).not_to be_valid(email) }
specify { expect(subject).not_to be_valid([email]) }
specify { expect(subject).not_to be_valid([value: 1, primary: true]) }
specify { expect(subject).not_to be_valid([value: email, primary: 'true']) }