Module: ClientSideValidations::ActiveRecord::Uniqueness

Defined in:
lib/client_side_validations/active_record/uniqueness.rb

Instance Method Summary collapse

Instance Method Details

#client_side_hash(model, attribute, _force = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/client_side_validations/active_record/uniqueness.rb', line 6

def client_side_hash(model, attribute, _force = nil)
  hash = {}
  hash[:message]        = model.errors.generate_message(attribute, message_type, options.except(:scope))
  hash[:case_sensitive] = true if options[:case_sensitive]
  hash[:id]             = model.id unless model.new_record?
  hash[:allow_blank]    = true if options[:allow_nil] || options[:allow_blank]

  apply_class_option! hash, model
  apply_scope_option! hash, model

  hash
end