Module: Scimitar::Errors

Included in:
ComplexTypes::Base, Resources::Base, Schema::Attribute
Defined in:
app/models/scimitar/errors.rb

Instance Method Summary collapse

Instance Method Details

#add_errors_from_hash(errors_hash:, prefix: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/models/scimitar/errors.rb', line 3

def add_errors_from_hash(errors_hash:, prefix: nil)
  errors_hash.each_pair do |key, value|
    new_key = prefix.nil? ? key : "#{prefix}.#{key}".to_sym
    if value.is_a?(Array)
      value.each {|error| errors.add(new_key, error)}
    else
      errors.add(new_key, value)
    end
  end
end