client_side_validations 4.2.12 → 6.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d645b444078a494c8ee5cc8bfd309dbb0333e29
4
- data.tar.gz: 9c9d3a9eb0a97533b8e1ee7c9330748769b45526
3
+ metadata.gz: 62857994d1326cfb20a2c2d3c1c5fd746fa72065
4
+ data.tar.gz: 5d187e21b9b0b8935f3d5bfee8099095a128a389
5
5
  SHA512:
6
- metadata.gz: 723c05eda13d578f4da7970b096459709da53b08653e08d5cead6ac01c9170cc221465fe0cd63bd75b85e721a44928952477df7cf1762a50747277b13ca77bea
7
- data.tar.gz: 2987e1b5145e88236dac5de8d6540f586177dc00840c302bb796a76b4ba7d22333858461c99cb600927ca1f1e42a06bba2720aaf05be3cddc0f99b468b48741a
6
+ metadata.gz: 284d47098c63a20c73aad2d252028e54ecd7b519d6130d16170206440e4f70b6e28f70be895a71c4f71dc555acf65765f1137acbded5910aa5aea779bdf3862a
7
+ data.tar.gz: 4c0b3c38d2254184cd34841d87683a3c21e0e5c1805be57134b913078f96e964e920cf78b85efb41a214f9bb81721b24e3e78996ca82e2877e751d15717cb6b2
data/CHANGELOG.md ADDED
@@ -0,0 +1,71 @@
1
+ # Changelog
2
+
3
+ ## 6.0.0 (2017-01-20)
4
+
5
+ * Rails 5.0 compatibility
6
+
7
+ ## 4.2.12 (2017-01-19)
8
+
9
+ * Add Changelog ([#688](https://github.com/DavyJonesLocker/client_side_validations/issues/688))
10
+ * Test against jQuery from 1.7.2 to 3.1.1
11
+ * Drop Ruby 2.0.0 support
12
+ * Other minor changes
13
+
14
+ ## 4.2.11 (2016-12-08)
15
+
16
+ * Fix conditional validators ([#686](https://github.com/DavyJonesLocker/client_side_validations/issues/686))
17
+
18
+ ## 4.2.10 (2016-11-16)
19
+
20
+ * Fix dollar sign in regular expression ([#684](https://github.com/DavyJonesLocker/client_side_validations/issues/684))
21
+
22
+ ## 4.2.9 (2016-11-11)
23
+
24
+ * Fix jQuery 3 compatibility
25
+
26
+ ## 4.2.8 (2016-11-11)
27
+
28
+ * Fix numericality validator ([#679](https://github.com/DavyJonesLocker/client_side_validations/pull/679))
29
+
30
+ ## 4.2.7 (2016-10-08)
31
+
32
+ * Fix: Prevent undesired `stopPropagation` on `focusout` event ([#675](https://github.com/DavyJonesLocker/client_side_validations/pull/675))
33
+
34
+ ## 4.2.6 (2016-09-10)
35
+
36
+ * Add some clarity to the `copy_assets` command ([#671](https://github.com/DavyJonesLocker/client_side_validations/pull/671))
37
+ * Other minor changes
38
+
39
+ ## 4.2.5 (2016-07-06)
40
+
41
+ * Fix: Make helpers consistent with their Rails counterparts ([#665](https://github.com/DavyJonesLocker/client_side_validations/issues/665))
42
+ * Other minor changes
43
+
44
+ ## 4.2.4 (2016-06-14)
45
+
46
+ * Add Turbolinks 5 compatibility
47
+ * Drop Ruby 1.9 support
48
+ * Test against Ruby 2.1.10, 2.2.5 and 2.3.1
49
+ * Test against jQuery 1.12.4
50
+
51
+ ## 4.2.3 (2016-03-14)
52
+
53
+ * Test against jQuery 1.12.1
54
+ * Other minor changes
55
+
56
+ ## 4.2.2 (2016-02-28)
57
+
58
+ * Fix uniqueness validator data disclosure ([#648](https://github.com/DavyJonesLocker/client_side_validations/issues/648))
59
+ * Fix config.root_path to work in middleware ([#598](https://github.com/DavyJonesLocker/client_side_validations/pull/598))
60
+ * Other minor changes
61
+
62
+ ## 4.2.1 (2016-01-15)
63
+
64
+ * Test against jQuery 1.12.0
65
+ * Other minor changes
66
+
67
+ ## 4.2.0 (2016-01-07)
68
+
69
+ * First Rails 4.x compatible version
70
+
71
+ For older versions, please refer to [GitHub releases](https://github.com/DavyJonesLocker/client_side_validations/releases)
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  [![Code Climate](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/badges/gpa.svg)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations)
7
7
  [![Coverage Status](https://coveralls.io/repos/github/DavyJonesLocker/client_side_validations/badge.svg?branch=master)](https://coveralls.io/github/DavyJonesLocker/client_side_validations?branch=master)
8
8
 
9
- `ClientSideValidations` made easy for your Rails 4 applications!
9
+ `ClientSideValidations` made easy for your Rails 5 applications!
10
10
 
11
11
  ## Project Goals ##
12
12
 
@@ -532,17 +532,6 @@ Note that the `FormBuilder` will automatically skip building validators that are
532
532
 
533
533
  This gem follows [Semantic Versioning](http://semver.org)
534
534
 
535
- Major and minor version numbers will follow `Rails`'s major and
536
- minor version numbers. For example,
537
- `client_side_validations-4.2.0` will be compatible up to
538
- `~> rails-4.2.0`
539
-
540
- We will maintain compatibility with one minor version back. So the 4.2.0 version of `client_side_validations`
541
- will be compatible with `~> rails-4.1.0`. We will not drop support
542
- to older versions if not necessary.
543
-
544
- Only two versions minor versions will be actively maintained.
545
-
546
535
  ## Want to help? ##
547
536
 
548
537
  Please do! We are always looking to improve this gem. Please see our
@@ -551,7 +540,7 @@ on how to properly submit issues and pull requests.
551
540
 
552
541
  ## Legal ##
553
542
 
554
- [DockYard](https://dockyard.com/), LLC © 2012-2016
543
+ [DockYard](https://dockyard.com/), LLC © 2012-2017
555
544
 
556
545
  [@dockyard](https://twitter.com/dockyard)
557
546
 
@@ -12,4 +12,4 @@ require 'client_side_validations/action_view/form_builder'
12
12
 
13
13
  ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormHelper)
14
14
  ActionView::Base.send(:include, ClientSideValidations::ActionView::Helpers::FormTagHelper)
15
- ActionView::Helpers::FormBuilder.send(:include, ClientSideValidations::ActionView::Helpers::FormBuilder)
15
+ ActionView::Helpers::FormBuilder.send(:prepend, ClientSideValidations::ActionView::Helpers::FormBuilder)
@@ -2,30 +2,21 @@ module ClientSideValidations
2
2
  module ActionView
3
3
  module Helpers
4
4
  module FormBuilder
5
- def self.included(base)
5
+ def self.prepended(base)
6
6
  (base.field_helpers.map(&:to_s) - %w(apply_form_for_options! label check_box radio_button fields_for hidden_field)).each do |selector|
7
7
  base.class_eval <<-RUBY_EVAL
8
- def #{selector}_with_client_side_validations(method, options = {})
8
+ def #{selector}(method, options = {})
9
9
  build_validation_options(method, options)
10
10
  options.delete(:validate)
11
- #{selector}_without_client_side_validations(method, options)
11
+
12
+ # Cannot call super here, override the whole method
13
+ @template.send( # @template.send(
14
+ #{selector.inspect}, # "text_field",
15
+ @object_name, # @object_name,
16
+ method, # method,
17
+ objectify_options(options)) # objectify_options(options))
12
18
  end
13
19
  RUBY_EVAL
14
-
15
- base.class_eval { alias_method_chain selector, :client_side_validations }
16
- end
17
-
18
- base.class_eval do
19
- alias_method_chain :initialize, :client_side_validations
20
- alias_method_chain :fields_for, :client_side_validations
21
- alias_method_chain :check_box, :client_side_validations
22
- alias_method_chain :radio_button, :client_side_validations
23
- alias_method_chain :select, :client_side_validations
24
- alias_method_chain :collection_select, :client_side_validations
25
- alias_method_chain :collection_check_boxes, :client_side_validations
26
- alias_method_chain :collection_radio_buttons, :client_side_validations
27
- alias_method_chain :grouped_collection_select, :client_side_validations
28
- alias_method_chain :time_zone_select, :client_side_validations
29
20
  end
30
21
  end
31
22
 
@@ -45,62 +36,58 @@ module ClientSideValidations
45
36
  nil
46
37
  end
47
38
 
48
- def initialize_with_client_side_validations(object_name, object, template, options)
49
- initialize_without_client_side_validations(object_name, object, template, options)
39
+ def initialize(object_name, object, template, options)
40
+ super(object_name, object, template, options)
50
41
  @options[:validators] = { object => {} }
51
42
  end
52
43
 
53
- def fields_for_with_client_side_validations(record_name, record_object = nil, fields_options = {}, &block)
44
+ def fields_for(record_name, record_object = nil, fields_options = {}, &block)
54
45
  fields_options[:validate] ||= @options[:validate] if @options[:validate] && !fields_options.key?(:validate)
55
- fields_for_without_client_side_validations(record_name, record_object, fields_options, &block)
46
+ super(record_name, record_object, fields_options, &block)
56
47
  end
57
48
 
58
- def check_box_with_client_side_validations(method, options = {}, checked_value = '1', unchecked_value = '0')
49
+ def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
59
50
  build_validation_options(method, options)
60
51
  options.delete(:validate)
61
- check_box_without_client_side_validations(method, options, checked_value, unchecked_value)
52
+ super(method, options, checked_value, unchecked_value)
62
53
  end
63
54
 
64
- def radio_button_with_client_side_validations(method, tag_value, options = {})
55
+ def radio_button(method, tag_value, options = {})
65
56
  build_validation_options(method, options)
66
57
  options.delete(:validate)
67
- radio_button_without_client_side_validations(method, tag_value, options)
58
+ super(method, tag_value, options)
68
59
  end
69
60
 
70
- def select_with_client_side_validations(method, choices = nil, options = {}, html_options = {}, &block)
61
+ def select(method, choices = nil, options = {}, html_options = {}, &block)
71
62
  build_validation_options(method, html_options.merge(name: options[:name]))
72
63
  html_options.delete(:validate)
73
- select_without_client_side_validations(method, choices, options, html_options, &block)
64
+ super(method, choices, options, html_options, &block)
74
65
  end
75
66
 
76
- def collection_select_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {})
67
+ def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
77
68
  build_validation_options(method, html_options.merge(name: options[:name]))
78
69
  html_options.delete(:validate)
79
- collection_select_without_client_side_validations(method, collection, value_method, text_method, options, html_options)
70
+ super(method, collection, value_method, text_method, options, html_options)
80
71
  end
81
72
 
82
- def collection_check_boxes_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
83
- build_validation_options(method, html_options.merge(name: options[:name]))
84
- html_options.delete(:validate)
85
- collection_check_boxes_without_client_side_validations(method, collection, value_method, text_method, options, html_options, &block)
86
- end
87
-
88
- def collection_radio_buttons_with_client_side_validations(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
89
- build_validation_options(method, html_options.merge(name: options[:name]))
90
- html_options.delete(:validate)
91
- collection_radio_buttons_without_client_side_validations(method, collection, value_method, text_method, options, html_options, &block)
73
+ %i(collection_check_boxes collection_radio_buttons).each do |method_name|
74
+ define_method method_name do |method, collection, value_method, text_method, options = {}, html_options = {}, &block|
75
+ build_validation_options(method, html_options.merge(name: options[:name]))
76
+ html_options.delete(:validate)
77
+ super(method, collection, value_method, text_method, options, html_options, &block)
78
+ end
92
79
  end
93
80
 
94
- 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
+ def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
95
82
  build_validation_options(method, html_options.merge(name: options[:name]))
96
83
  html_options.delete(:validate)
97
- grouped_collection_select_without_client_side_validations(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
84
+ super(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
98
85
  end
99
86
 
100
- def time_zone_select_with_client_side_validations(method, priority_zones = nil, options = {}, html_options = {})
87
+ def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
101
88
  build_validation_options(method, html_options.merge(name: options[:name]))
102
89
  html_options.delete(:validate)
103
- time_zone_select_without_client_side_validations(method, priority_zones, options, html_options)
90
+ super(method, priority_zones, options, html_options)
104
91
  end
105
92
 
106
93
  private
@@ -6,22 +6,23 @@ module ClientSideValidations
6
6
  end
7
7
 
8
8
  def self.unique?(klass, attribute, value, params)
9
- klass = find_topmost_superclass(klass)
10
- column = klass.columns_hash[attribute.to_s]
11
- value = type_cast_value(column, value)
9
+ klass = find_topmost_superclass(klass)
10
+ connection = klass.connection
11
+ column = klass.columns_hash[attribute.to_s]
12
+ value = type_cast_value(connection, column, value)
12
13
 
13
- sql = sql_statement(klass, attribute, value, params)
14
+ sql = sql_statement(klass, connection, attribute, value, params)
14
15
  relation = Arel::Nodes::SqlLiteral.new(sql)
15
16
 
16
17
  klass.where(relation).empty?
17
18
  end
18
19
 
19
- def self.sql_statement(klass, attribute, value, params)
20
+ def self.sql_statement(klass, connection, attribute, value, params)
20
21
  sql = []
21
22
  t = klass.arel_table
22
23
 
23
24
  if params[:case_sensitive] == 'true'
24
- sql << 'BINARY' if t.engine.connection.adapter_name =~ /^mysql/i
25
+ sql << 'BINARY' if connection.adapter_name =~ /^mysql/i
25
26
  sql << t[attribute].eq(value).to_sql
26
27
  else
27
28
  escaped_value = value.gsub(/[%_]/, '\\\\\0')
@@ -31,20 +32,16 @@ module ClientSideValidations
31
32
  sql << "AND #{t[klass.primary_key].not_eq(params[:id]).to_sql}" if params[:id]
32
33
 
33
34
  (params[:scope] || {}).each do |scope_attribute, scope_value|
34
- scope_value = type_cast_value(klass.columns_hash[scope_attribute], scope_value)
35
+ scope_value = type_cast_value(connection, klass.columns_hash[scope_attribute], scope_value)
35
36
  sql << "AND #{t[scope_attribute].eq(scope_value).to_sql}"
36
37
  end
37
38
 
38
39
  sql.join ' '
39
40
  end
40
41
 
41
- def self.type_cast_value(column, value)
42
- value =
43
- if column.respond_to?(:type_cast)
44
- column.type_cast(value)
45
- else
46
- column.type_cast_from_database(value)
47
- end
42
+ def self.type_cast_value(connection, column, value)
43
+ type = connection.lookup_cast_type_from_column(column)
44
+ value = type.deserialize(value)
48
45
 
49
46
  if column.limit && value.is_a?(String)
50
47
  value.mb_chars[0, column.limit]
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ClientSideValidations
3
- VERSION = '4.2.12'.freeze
3
+ VERSION = '6.0.0'.freeze
4
4
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Client Side Validations - v4.2.12 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Client Side Validations - v6.0.0 (https://github.com/DavyJonesLocker/client_side_validations)
4
4
  * Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
5
5
  * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
6
6
  */
@@ -469,7 +469,9 @@
469
469
  }
470
470
  },
471
471
  confirmation: function(element, options) {
472
- if (element.val() !== $("#" + (element.attr('id')) + "_confirmation").val()) {
472
+ var regex;
473
+ regex = new RegExp("^" + (element.val()) + "$", options.case_sensitive ? '' : 'i');
474
+ if (!regex.test($("#" + (element.attr('id')) + "_confirmation").val())) {
473
475
  return options.message;
474
476
  }
475
477
  },
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.12
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -9,68 +9,56 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-01-19 00:00:00.000000000 Z
12
+ date: 2017-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 4.0.0
21
- - - "<"
20
+ version: 5.0.0
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 4.3.0
23
+ version: 5.0.0.1
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ">="
28
+ - - "~>"
29
29
  - !ruby/object:Gem::Version
30
- version: 4.0.0
31
- - - "<"
30
+ version: 5.0.0
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.3.0
33
+ version: 5.0.0.1
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: jquery-rails
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 3.1.2
41
- - - "<"
38
+ - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: 5.0.0
40
+ version: '4.2'
44
41
  type: :runtime
45
42
  prerelease: false
46
43
  version_requirements: !ruby/object:Gem::Requirement
47
44
  requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: 3.1.2
51
- - - "<"
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: 5.0.0
47
+ version: '4.2'
54
48
  - !ruby/object:Gem::Dependency
55
49
  name: js_regex
56
50
  requirement: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '1.0'
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: 1.0.19
54
+ version: '1.2'
64
55
  type: :runtime
65
56
  prerelease: false
66
57
  version_requirements: !ruby/object:Gem::Requirement
67
58
  requirements:
68
59
  - - "~>"
69
60
  - !ruby/object:Gem::Version
70
- version: '1.0'
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: 1.0.19
61
+ version: '1.2'
74
62
  - !ruby/object:Gem::Dependency
75
63
  name: appraisal
76
64
  requirement: !ruby/object:Gem::Requirement
@@ -223,14 +211,14 @@ dependencies:
223
211
  requirements:
224
212
  - - "~>"
225
213
  - !ruby/object:Gem::Version
226
- version: '1.4'
214
+ version: 2.0.0.beta2
227
215
  type: :development
228
216
  prerelease: false
229
217
  version_requirements: !ruby/object:Gem::Requirement
230
218
  requirements:
231
219
  - - "~>"
232
220
  - !ruby/object:Gem::Version
233
- version: '1.4'
221
+ version: 2.0.0.beta2
234
222
  - !ruby/object:Gem::Dependency
235
223
  name: shotgun
236
224
  requirement: !ruby/object:Gem::Requirement
@@ -273,7 +261,7 @@ dependencies:
273
261
  - - "~>"
274
262
  - !ruby/object:Gem::Version
275
263
  version: '2.4'
276
- description: Client Side Validations made easy for your Rails 4 applications
264
+ description: Client Side Validations made easy for your Rails 5 applications
277
265
  email:
278
266
  - tagliala.dev@gmail.com
279
267
  - bcardarella@gmail.com
@@ -281,6 +269,7 @@ executables: []
281
269
  extensions: []
282
270
  extra_rdoc_files: []
283
271
  files:
272
+ - CHANGELOG.md
284
273
  - README.md
285
274
  - lib/client_side_validations.rb
286
275
  - lib/client_side_validations/action_view.rb
@@ -334,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
323
  version: '0'
335
324
  requirements: []
336
325
  rubyforge_project:
337
- rubygems_version: 2.5.2
326
+ rubygems_version: 2.6.8
338
327
  signing_key:
339
328
  specification_version: 4
340
329
  summary: Client Side Validations