Module: Solid::Validators

Defined in:
lib/solid/validators.rb

Class Method Summary collapse

Class Method Details

.add_error(model, attribute, message, options) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/solid/validators.rb', line 5

def self.add_error(model, attribute, message, options)
  if ActiveModel.const_defined?(:Error)
    model.errors.add(attribute, **options.merge(message: message))
  else
    model.errors.add(attribute, options.fetch(:message, message))
  end
end