634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
# File 'lib/attributor/types/hash.rb', line 634
def validate(context = Attributor::DEFAULT_ROOT_CONTEXT)
@validating = true
context = [context] if context.is_a? ::String
if self.class.keys.any?
= @contents.keys - self.class.keys.keys
if .any? && !self.class.options[:allow_extra]
return .collect do |k|
"#{Attributor.humanize_context(context)} can not have key: #{k.inspect}"
end
end
self.validate_keys(context)
else
self.validate_generic(context)
end
ensure
@validating = false
end
|