15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/client_side_validations/active_model/numericality.rb', line 15
def client_side_hash(model, attribute, force = nil)
options = self.options.dup
hash = options_hash(model, attribute, options)
@@option_map.each do |option, message_type|
count = options[option]
next unless count
if count.respond_to?(:call)
next unless force
count = count.call(model)
end
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(count: count))
hash[option] = count
end
copy_conditional_attributes(hash, options)
hash
end
|