29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/client_side_validations/active_model.rb', line 29
def client_side_validation_hash(force = nil)
_validators.inject({}) do |attr_hash, attr|
return attr_hash if [nil, :block].include?(attr[0])
validator_hash = attr[1].each_with_object(Hash.new { |h, k| h[k] = [] }) do |validator, kind_hash|
next unless can_use_for_client_side_validation?(attr[0], validator, force)
client_side_hash = validator.client_side_hash(self, attr[0], (attr[0], force))
if client_side_hash
kind_hash[validator.kind] << client_side_hash.except(:on, :if, :unless)
end
end
if validator_hash.present?
attr_hash.merge!(attr[0] => validator_hash)
else
attr_hash
end
end
end
|