4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/client_side_validations/active_model/length.rb', line 4
def client_side_hash(model, attribute)
= options.except(*::ActiveModel::Errors::CALLBACKS_OPTIONS - [:allow_blank, :on]).except(:tokenizer, :too_long, :too_short, :wrong_length)
errors_options = options.except(*self.class::RESERVED_OPTIONS)
messages = .except(:js_tokenizer, :allow_blank, :on).keys.inject({}) do |hash, key|
errors_options[:count] = [key]
count = [key]
default_message = options[self.class::MESSAGES[key]]
errors_options[:message] ||= default_message if default_message
hash.merge!(key => model.errors.generate_message(attribute, self.class::MESSAGES[key], errors_options))
end
{ :messages => messages }.merge()
end
|