rails4_client_side_validations 0.0.4 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -7
- data/lib/client_side_validations.rb +12 -0
- data/lib/client_side_validations/action_view.rb +13 -0
- data/lib/client_side_validations/action_view/form_builder.rb +105 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/action_view/form_helper.rb +13 -17
- data/lib/client_side_validations/action_view/form_tag_helper.rb +11 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model.rb +31 -9
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/absence.rb +1 -2
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/acceptance.rb +1 -2
- data/lib/client_side_validations/active_model/exclusion.rb +7 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/format.rb +1 -2
- data/lib/client_side_validations/active_model/inclusion.rb +7 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/length.rb +3 -4
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/numericality.rb +3 -4
- data/lib/{rails4_client_side_validations → client_side_validations}/active_model/presence.rb +1 -2
- data/lib/client_side_validations/active_record.rb +12 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/active_record/middleware.rb +10 -6
- data/lib/{rails4_client_side_validations → client_side_validations}/active_record/uniqueness.rb +8 -6
- data/lib/{rails4_client_side_validations → client_side_validations}/config.rb +1 -1
- data/lib/client_side_validations/core_ext.rb +3 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/core_ext/range.rb +0 -1
- data/lib/client_side_validations/core_ext/regexp.rb +25 -0
- data/lib/client_side_validations/engine.rb +5 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/files.rb +2 -2
- data/lib/{rails4_client_side_validations → client_side_validations}/generators.rb +2 -3
- data/lib/client_side_validations/generators/rails_validations.rb +14 -0
- data/lib/{rails4_client_side_validations → client_side_validations}/middleware.rb +61 -16
- data/lib/client_side_validations/version.rb +3 -0
- data/lib/generators/{rails4_client_side_validations → client_side_validations}/copy_assets_generator.rb +3 -5
- data/lib/generators/client_side_validations/install_generator.rb +21 -0
- data/lib/generators/templates/{rails4_client_side_validations → client_side_validations}/initializer.rb +4 -4
- data/vendor/assets/javascripts/rails.validations.js +111 -98
- metadata +141 -81
- data/lib/generators/rails4_client_side_validations/install_generator.rb +0 -22
- data/lib/rails4_client_side_validations.rb +0 -13
- data/lib/rails4_client_side_validations/action_view.rb +0 -14
- data/lib/rails4_client_side_validations/action_view/form_builder.rb +0 -105
- data/lib/rails4_client_side_validations/action_view/form_tag_helper.rb +0 -12
- data/lib/rails4_client_side_validations/active_model/exclusion.rb +0 -27
- data/lib/rails4_client_side_validations/active_model/inclusion.rb +0 -26
- data/lib/rails4_client_side_validations/active_record.rb +0 -12
- data/lib/rails4_client_side_validations/core_ext.rb +0 -3
- data/lib/rails4_client_side_validations/core_ext/regexp.rb +0 -13
- data/lib/rails4_client_side_validations/engine.rb +0 -6
- data/lib/rails4_client_side_validations/generators/rails_validations.rb +0 -15
- data/lib/rails4_client_side_validations/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b093c6b17d7b641997d3bfbbb4e98726b1de02
|
4
|
+
data.tar.gz: 62995c5131322f8dcd4d67a7c8c551906a71a34c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2fb46377e7241745c17ce084fe160af267a1aa0f902379212ba77fc426c4be96a35746e83b52422d93a1fc476b9dc5e9c66cb95cb9bd8af7ee1ce545a15b24a
|
7
|
+
data.tar.gz: f33e5a9bc2c6dee2387d8fc8f4c78ad614a596b6f433a98431477f268f11e06fcdd6a55b1dfb57dffbea66a823456f5b978930a36e9e8a395c6c8c9899541a46
|
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
[
|
2
|
-
[](https://travis-ci.org/kalkov/rails4_client_side_validations)
|
3
|
-
[](https://codeclimate.com/github/kalkov/rails4_client_side_validations)
|
4
|
-
[](https://gemnasium.com/kalkov/rails4_client_side_validations)
|
1
|
+
Original repo is here: [client_side_validations](https://github.com/DavyJonesLocker/client_side_validations)
|
5
2
|
|
3
|
+
The purpose ot this repo is that you can install it like a 'normal' gem from rubygems, instead of Github.
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'rails4_client_side_validations'
|
10
|
+
```
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Same as original gem.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module ClientSideValidations
|
2
|
+
end
|
3
|
+
|
4
|
+
require 'client_side_validations/config'
|
5
|
+
require 'client_side_validations/active_model' if defined?(::ActiveModel)
|
6
|
+
require 'client_side_validations/active_record' if defined?(::ActiveRecord)
|
7
|
+
require 'client_side_validations/action_view' if defined?(::ActionView)
|
8
|
+
if defined?(::Rails)
|
9
|
+
require 'client_side_validations/generators'
|
10
|
+
require 'client_side_validations/middleware'
|
11
|
+
require 'client_side_validations/engine'
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ClientSideValidations::ActionView
|
2
|
+
module Helpers
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
require 'client_side_validations/core_ext'
|
7
|
+
require 'client_side_validations/action_view/form_helper'
|
8
|
+
require 'client_side_validations/action_view/form_tag_helper'
|
9
|
+
require 'client_side_validations/action_view/form_builder'
|
10
|
+
|
11
|
+
ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormHelper)
|
12
|
+
ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormTagHelper)
|
13
|
+
ActionView::Helpers::FormBuilder.send(:include, ClientSideValidations::ActionView::Helpers::FormBuilder)
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module ClientSideValidations::ActionView::Helpers
|
2
|
+
module FormBuilder
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
(base.field_helpers.map(&:to_s) - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector|
|
6
|
+
base.class_eval <<-RUBY_EVAL
|
7
|
+
def #{selector}_with_client_side_validations(method, options = {})
|
8
|
+
build_validation_options(method, options)
|
9
|
+
options.delete(:validate)
|
10
|
+
#{selector}_without_client_side_validations(method, options)
|
11
|
+
end
|
12
|
+
RUBY_EVAL
|
13
|
+
|
14
|
+
base.class_eval { alias_method_chain selector, :client_side_validations }
|
15
|
+
end
|
16
|
+
|
17
|
+
base.class_eval do
|
18
|
+
alias_method_chain :initialize, :client_side_validations
|
19
|
+
alias_method_chain :fields_for, :client_side_validations
|
20
|
+
alias_method_chain :check_box, :client_side_validations
|
21
|
+
alias_method_chain :radio_button, :client_side_validations
|
22
|
+
alias_method_chain :select, :client_side_validations
|
23
|
+
alias_method_chain :collection_select, :client_side_validations
|
24
|
+
alias_method_chain :grouped_collection_select, :client_side_validations
|
25
|
+
alias_method_chain :time_zone_select, :client_side_validations
|
26
|
+
|
27
|
+
def client_side_form_settings(options, form_helper)
|
28
|
+
{
|
29
|
+
type: self.class.to_s,
|
30
|
+
input_tag: form_helper.class.field_error_proc.call(%{<span id="input_tag" />}, Struct.new(:error_message, :tag_id).new([], "")),
|
31
|
+
label_tag: form_helper.class.field_error_proc.call(%{<label id="label_tag" />}, Struct.new(:error_message, :tag_id).new([], ""))
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def validate(*attrs)
|
38
|
+
options = attrs.pop if attrs.last.is_a?(Hash)
|
39
|
+
(attrs.present? ? attrs : @object._validators.keys).each do |attr|
|
40
|
+
build_validation_options(attr, validate: options)
|
41
|
+
end
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize_with_client_side_validations(object_name, object, *args)
|
46
|
+
initialize_without_client_side_validations(object_name, object, *args)
|
47
|
+
@options[:validators] = { object => {} }
|
48
|
+
end
|
49
|
+
|
50
|
+
def fields_for_with_client_side_validations(record_or_name_or_array, *args, &block)
|
51
|
+
options = args.extract_options!
|
52
|
+
options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
|
53
|
+
fields_for_without_client_side_validations(record_or_name_or_array, *(args << options), &block)
|
54
|
+
end
|
55
|
+
|
56
|
+
def check_box_with_client_side_validations(method, options = {}, checked_value = "1", unchecked_value = "0")
|
57
|
+
build_validation_options(method, options)
|
58
|
+
options.delete(:validate)
|
59
|
+
check_box_without_client_side_validations(method, options, checked_value, unchecked_value)
|
60
|
+
end
|
61
|
+
|
62
|
+
def radio_button_with_client_side_validations(method, tag_value, options = {})
|
63
|
+
build_validation_options(method, options)
|
64
|
+
options.delete(:validate)
|
65
|
+
radio_button_without_client_side_validations(method, tag_value, options)
|
66
|
+
end
|
67
|
+
|
68
|
+
def select_with_client_side_validations(method, choices, options = {}, html_options = {})
|
69
|
+
build_validation_options(method, html_options.merge(name: options[:name]))
|
70
|
+
html_options.delete(:validate)
|
71
|
+
select_without_client_side_validations(method, choices, options, html_options)
|
72
|
+
end
|
73
|
+
|
74
|
+
def collection_select_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {})
|
75
|
+
build_validation_options(method, html_options.merge(name: options[:name]))
|
76
|
+
html_options.delete(:validate)
|
77
|
+
collection_select_without_client_side_validations(method, collection, value_method, text_method, options, html_options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def grouped_collection_select_with_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
81
|
+
build_validation_options(method, html_options.merge(name: options[:name]))
|
82
|
+
html_options.delete(:validate)
|
83
|
+
grouped_collection_select_without_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def time_zone_select_with_client_side_validations(method, priority_zones = nil, options = {}, html_options = {})
|
87
|
+
build_validation_options(method, html_options.merge(name: options[:name]))
|
88
|
+
html_options.delete(:validate)
|
89
|
+
time_zone_select_without_client_side_validations(method, priority_zones, options, html_options)
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def build_validation_options(method, options = {})
|
95
|
+
if @options[:validate]
|
96
|
+
index = @default_options[:index].present? ? "[#{@default_options[:index]}]" : ''
|
97
|
+
name = options[:name] || "#{@object_name}#{index}[#{method}]"
|
98
|
+
child_index = @options[:child_index] ? "(\\d+|#{Regexp.escape(@options[:child_index].to_s)})" : "\\d+"
|
99
|
+
name = name.to_s.gsub(/_attributes\]\[#{child_index}\]/, '_attributes][]')
|
100
|
+
name = "#{name}#{options[:multiple] ? "[]" : nil}"
|
101
|
+
@options[:validators][@object][method] = { name: name, options: options[:validate] }
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/{rails4_client_side_validations → client_side_validations}/action_view/form_helper.rb
RENAMED
@@ -1,10 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module ClientSideValidations::ActionView::Helpers
|
2
2
|
module FormHelper
|
3
3
|
class Error < StandardError; end
|
4
4
|
|
5
|
-
def form_for(record,
|
5
|
+
def form_for(record, options = {}, &block)
|
6
6
|
raise ArgumentError, "Missing block" unless block_given?
|
7
|
-
options = args.extract_options!
|
8
7
|
if options[:validate]
|
9
8
|
|
10
9
|
# Always turn off HTML5 Validations
|
@@ -13,7 +12,7 @@ module Rails4ClientSideValidations::ActionView::Helpers
|
|
13
12
|
|
14
13
|
case record
|
15
14
|
when String, Symbol
|
16
|
-
raise
|
15
|
+
raise ClientSideValidations::ActionView::Helpers::FormHelper::Error, 'Using form_for(:name, @resource) is not supported with ClientSideValidations. Please use form_for(@resource, as: :name) instead.'
|
17
16
|
else
|
18
17
|
object = record.is_a?(Array) ? record.last : record
|
19
18
|
object_name = options[:as] || model_name_from_record_or_class(object).param_key
|
@@ -24,12 +23,11 @@ module Rails4ClientSideValidations::ActionView::Helpers
|
|
24
23
|
|
25
24
|
# Order matters here. Rails mutates the options object
|
26
25
|
html_id = options[:html][:id] if options[:html]
|
27
|
-
form = super(record,
|
26
|
+
form = super(record, options, &block)
|
28
27
|
options[:id] = html_id if html_id
|
29
28
|
|
30
|
-
|
29
|
+
build_bound_validators options
|
31
30
|
builder = instantiate_builder(object_name, object, options) if object_name and object
|
32
|
-
|
33
31
|
script = client_side_form_settings(object, options, builder)
|
34
32
|
|
35
33
|
# Because of the load order requirement above this sub is necessary
|
@@ -50,20 +48,20 @@ module Rails4ClientSideValidations::ActionView::Helpers
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
def apply_form_for_options!(
|
51
|
+
def apply_form_for_options!(record, object, options)
|
54
52
|
super
|
55
53
|
options[:html][:validate] = true if options[:validate]
|
56
54
|
end
|
57
55
|
|
58
56
|
def fields_for(record_or_name_or_array, record_object = nil, options = {}, &block)
|
59
57
|
output = super
|
60
|
-
|
58
|
+
build_bound_validators options
|
61
59
|
output
|
62
60
|
end
|
63
61
|
|
64
62
|
private
|
65
63
|
|
66
|
-
def
|
64
|
+
def build_bound_validators(options)
|
67
65
|
if @validators
|
68
66
|
options[:validators].each do |key, value|
|
69
67
|
if @validators.key?(key)
|
@@ -120,20 +118,18 @@ module Rails4ClientSideValidations::ActionView::Helpers
|
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
123
|
-
if
|
124
|
-
number_format = I18n.t(
|
121
|
+
if ClientSideValidations::Config.number_format_with_locale and defined?(I18n)
|
122
|
+
number_format = I18n.t('number.format').slice(:separator, :delimiter)
|
125
123
|
else
|
126
|
-
number_format = {:
|
124
|
+
number_format = { separator:'.', delimiter:',' }
|
127
125
|
end
|
128
|
-
patterns = {:
|
126
|
+
patterns = { numericality:"/^(-|\\+)?(?:\\d+|\\d{1,3}(?:\\#{number_format[:delimiter]}\\d{3})+)(?:\\#{number_format[:separator]}\\d*)?$/" }
|
129
127
|
|
130
128
|
|
131
129
|
content_tag(:script) do
|
132
|
-
"//<![CDATA[\nif(window.
|
130
|
+
"//<![CDATA[\nif(window.ClientSideValidations===undefined)window.ClientSideValidations={};window.ClientSideValidations.disabled_validators=#{ClientSideValidations::Config.disabled_validators.to_json};window.ClientSideValidations.number_format=#{number_format.to_json};if(window.ClientSideValidations.patterns===undefined)window.ClientSideValidations.patterns = {};window.ClientSideValidations.patterns.numericality=#{patterns[:numericality]};#{"if(window.ClientSideValidations.remote_validators_prefix===undefined)window.ClientSideValidations.remote_validators_prefix='#{(ClientSideValidations::Config.root_path).sub(/\/+\Z/,'')}';" if ClientSideValidations::Config.root_path.present? }if(window.ClientSideValidations.forms===undefined)window.ClientSideValidations.forms={};window.ClientSideValidations.forms['#{var_name}'] = #{builder.client_side_form_settings(options, self).merge(validators: 'validator_hash').to_json};\n//]]>".html_safe
|
133
131
|
end
|
134
132
|
end
|
135
133
|
end
|
136
|
-
|
137
134
|
end
|
138
135
|
end
|
139
|
-
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ClientSideValidations::ActionView::Helpers
|
2
|
+
module FormTagHelper
|
3
|
+
private
|
4
|
+
def html_options_for_form(url_for_options, options)
|
5
|
+
options.stringify_keys!
|
6
|
+
html_options = {}
|
7
|
+
html_options['data-validate'] = options.delete('validate') if options['validate']
|
8
|
+
html_options.merge!(super(url_for_options, options))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'client_side_validations/core_ext'
|
2
2
|
|
3
|
-
module
|
3
|
+
module ClientSideValidations::ActiveModel
|
4
4
|
module Validator
|
5
5
|
|
6
6
|
def client_side_hash(model, attribute, force = nil)
|
@@ -14,7 +14,7 @@ module Rails4ClientSideValidations::ActiveModel
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def build_client_side_hash(model, attribute, options)
|
17
|
-
{ :
|
17
|
+
{ message: model.errors.generate_message(attribute, message_type, options) }.merge(options.except(*::ActiveModel::Errors::CALLBACKS_OPTIONS - [:allow_blank, :if, :unless]))
|
18
18
|
end
|
19
19
|
|
20
20
|
def message_type
|
@@ -108,7 +108,7 @@ module Rails4ClientSideValidations::ActiveModel
|
|
108
108
|
false
|
109
109
|
end
|
110
110
|
else
|
111
|
-
::
|
111
|
+
::ClientSideValidations::Config.disabled_validators.include?(validator.kind)
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
@@ -130,14 +130,36 @@ module Rails4ClientSideValidations::ActiveModel
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
|
+
|
134
|
+
module EnumerableValidator
|
135
|
+
def client_side_hash(model, attribute, force = nil)
|
136
|
+
options = self.options.dup
|
137
|
+
if options[:in].respond_to?(:call)
|
138
|
+
if force
|
139
|
+
options[:in] = options[:in].call(model)
|
140
|
+
hash = build_client_side_hash(model, attribute, options)
|
141
|
+
else
|
142
|
+
return
|
143
|
+
end
|
144
|
+
else
|
145
|
+
hash = build_client_side_hash(model, attribute, options)
|
146
|
+
end
|
147
|
+
|
148
|
+
if hash[:in].is_a?(Range)
|
149
|
+
hash[:range] = hash[:in]
|
150
|
+
hash.delete(:in)
|
151
|
+
end
|
152
|
+
|
153
|
+
hash
|
154
|
+
end
|
155
|
+
end
|
133
156
|
end
|
134
157
|
|
135
|
-
ActiveModel::Validator.send(:include,
|
136
|
-
ActiveModel::Validations.send(:include,
|
158
|
+
ActiveModel::Validator.send(:include, ClientSideValidations::ActiveModel::Validator)
|
159
|
+
ActiveModel::Validations.send(:include, ClientSideValidations::ActiveModel::Validations)
|
137
160
|
|
138
161
|
%w{absence acceptance exclusion inclusion length format numericality presence}.each do |validator|
|
139
|
-
require "
|
162
|
+
require "client_side_validations/active_model/#{validator}"
|
140
163
|
validator.capitalize!
|
141
|
-
eval "ActiveModel::Validations::#{validator}Validator.send(:include,
|
164
|
+
eval "ActiveModel::Validations::#{validator}Validator.send(:include, ClientSideValidations::ActiveModel::#{validator})"
|
142
165
|
end
|
143
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ClientSideValidations::ActiveModel
|
2
2
|
module Format
|
3
3
|
def client_side_hash(model, attribute, force = nil)
|
4
4
|
options = self.options.dup
|
@@ -28,4 +28,3 @@ module Rails4ClientSideValidations::ActiveModel
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module
|
1
|
+
module ClientSideValidations::ActiveModel
|
2
2
|
module Length
|
3
3
|
|
4
4
|
def client_side_hash(model, attribute, force = nil)
|
5
5
|
options = self.options.dup
|
6
|
-
hash = { :
|
6
|
+
hash = { messages: {} }
|
7
7
|
hash[:js_tokenizer] = options[:js_tokenizer] if options[:js_tokenizer]
|
8
8
|
hash[:allow_blank] = true if options[:allow_blank]
|
9
9
|
|
@@ -11,7 +11,7 @@ module Rails4ClientSideValidations::ActiveModel
|
|
11
11
|
if count = options[option]
|
12
12
|
options[:message] = options[message_type] if options[message_type].present?
|
13
13
|
options.delete(:message) if options[:message].nil?
|
14
|
-
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(:
|
14
|
+
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(count: count))
|
15
15
|
hash[option] = count
|
16
16
|
end
|
17
17
|
end
|
@@ -23,4 +23,3 @@ module Rails4ClientSideValidations::ActiveModel
|
|
23
23
|
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
data/lib/{rails4_client_side_validations → client_side_validations}/active_model/numericality.rb
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ClientSideValidations::ActiveModel
|
2
2
|
module Numericality
|
3
3
|
|
4
4
|
OPTION_MAP = {}
|
@@ -9,7 +9,7 @@ module Rails4ClientSideValidations::ActiveModel
|
|
9
9
|
|
10
10
|
def client_side_hash(model, attribute, force = nil)
|
11
11
|
options = self.options.dup
|
12
|
-
hash = { :
|
12
|
+
hash = { messages: { numericality: model.errors.generate_message(attribute, :not_a_number, options) } }
|
13
13
|
|
14
14
|
if options[:only_integer]
|
15
15
|
hash[:messages][:only_integer] = model.errors.generate_message(attribute, :not_an_integer, options)
|
@@ -27,7 +27,7 @@ module Rails4ClientSideValidations::ActiveModel
|
|
27
27
|
next
|
28
28
|
end
|
29
29
|
end
|
30
|
-
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(:
|
30
|
+
hash[:messages][option] = model.errors.generate_message(attribute, message_type, options.merge(count: count))
|
31
31
|
hash[option] = count
|
32
32
|
end
|
33
33
|
end
|
@@ -39,4 +39,3 @@ module Rails4ClientSideValidations::ActiveModel
|
|
39
39
|
|
40
40
|
end
|
41
41
|
end
|
42
|
-
|