client_side_validations 19.0.0 → 20.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 519cbe68a2ab8902fda80886a2e802995699c9ffe177ff065bb84625c445cadf
4
- data.tar.gz: be55ec78e3fc953df50882bcc6a068025136c28b15231f08afdac2308d92dcfd
3
+ metadata.gz: 425f8909a6f06e2e3517c641b9f04627bec7e2c7b7a95ec79da2a471b30a156d
4
+ data.tar.gz: 17ff1058ef71b8456b9de695363bf58351054641de0b94d472b15d7c33cee788
5
5
  SHA512:
6
- metadata.gz: ad7a540ddcc1d61b6197789a4f1b16cba3c9d3ebe1aa512536b60996df4bf154fc8cb7cab5ac9aa29615adbe08af56890b95626e321fce068d083d8ba22dd764
7
- data.tar.gz: 7c13e4d20cb92ac469781d13e1395fe14b6cb69d8e3dfee0f20bdbd6f65ffa343e3d3d6de01f4b13c7af2ac0b70e44bdbd77737e7db9ee493b3223f769e2dcc4
6
+ metadata.gz: 803c6e9370de4a64b0a491e6ca81a889224a0a17abce24975131a4067deff9d7495a1480ca6b4e78b737106b4ee50a72e945d05e83899d68d187434138bac08d
7
+ data.tar.gz: 3bfe946cad1d6858a2e91fbad1d12b69b9564f9895189839681bf0663b1d8a53dcce868f5bfcf48bf59ce8b68c892e71e0b839f1d5b927b0d66ede1fec7cda9b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 20.0.1 / 2021-12-22
4
+
5
+ * [BUGFIX] Fix missing HTTP method ([#867](https://github.com/DavyJonesLocker/client_side_validations/issue/867))
6
+ * [ENHANCEMENT] Update development dependencies
7
+
8
+ ## 20.0.0 / 2021-12-16
9
+
10
+ * [FEATURE] Add Rails 7 compatibility - POSSIBLE BREAKING CHANGE ([#862](https://github.com/DavyJonesLocker/client_side_validations/pull/862))
11
+ * [ENHANCEMENT] Update development dependencies
12
+
13
+ ## 19.1.1 / 2021-11-15
14
+
15
+ * [ENHANCEMENT] Require MFA to publish gems
16
+ * [ENHANCEMENT] Update development dependencies
17
+
18
+ ## 19.1.0 / 2021-10-05
19
+
20
+ * [FEATURE] Add Turbo compatibility ([#849](https://github.com/DavyJonesLocker/client_side_validations/pull/849))
21
+
3
22
  ## 19.0.0 / 2021-10-01
4
23
 
5
24
  * [FEATURE] Add support to `other_than` numericality validator
data/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/client_side_validations.svg)](https://badge.fury.io/rb/client_side_validations)
4
4
  [![npm version](https://badge.fury.io/js/%40client-side-validations%2Fclient-side-validations.svg)](https://badge.fury.io/js/%40client-side-validations%2Fclient-side-validations)
5
- [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=client_side_validations&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=client_side_validations&package-manager=bundler&version-scheme=semver)
6
- [![Build Status](https://github.com/DavyJonesLocker/client_side_validations/actions/workflows/ruby.yml/badge.svg)](https://github.com/DavyJonesLocker/client_side_validations/actions)
5
+ [![Ruby Build Status](https://github.com/DavyJonesLocker/client_side_validations/actions/workflows/ruby.yml/badge.svg)](https://github.com/DavyJonesLocker/client_side_validations/actions)
6
+ [![JavaScript Build Status](https://github.com/DavyJonesLocker/client_side_validations/actions/workflows/javascript.yml/badge.svg)](https://github.com/DavyJonesLocker/client_side_validations/actions)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/9f9e8bb6edc92615f34e/maintainability)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/maintainability)
8
8
  [![Coverage Status](https://coveralls.io/repos/github/DavyJonesLocker/client_side_validations/badge.svg?branch=main)](https://coveralls.io/github/DavyJonesLocker/client_side_validations?branch=main)
9
9
 
10
10
 
11
- `ClientSideValidations` made easy for your Rails 5.2 / Rails 6.x applications!
11
+ `ClientSideValidations` made easy for your Rails 5.2 / 6.x / 7.0 applications!
12
12
 
13
13
  ## Project Goals ##
14
14
 
@@ -78,17 +78,17 @@ import '@client-side-validations/client-side-validations/src'
78
78
  require('@client-side-validations/client-side-validations')
79
79
  ```
80
80
 
81
- ##### Heads-up for Turbolinks users #####
81
+ ##### Heads-up for Turbo and Turbolinks users #####
82
+
83
+ If you are using [Turbo](https://github.com/hotwired/turbo-rails), use the
84
+ `import` syntax and make sure that `@client-side-validations/client-side-validations/src`
85
+ is imported **after** `@hotwired/turbo-rails`, so ClientSideValidations can properly detect
86
+ `window.Turbo` and attach its event handlers.
82
87
 
83
88
  If you are using [Turbolinks](https://github.com/turbolinks/turbolinks) 5.2,
84
- use the require syntax and make sure that `@client-side-validations/client-side-validations`
85
- is required after`Turbolinks.start()`, so ClientSideValidations can properly
86
- attach its event handlers.
87
-
88
- Turbolinks 5.3 automatically calls `start()`, so you can use the `import` syntax.
89
- Just make sure that `@client-side-validations/client-side-validations` is imported
90
- **after** `turbolinks`, so ClientSideValidations can properly
91
- attach its event handlers.
89
+ use the `require` syntax and make sure that `@client-side-validations/client-side-validations`
90
+ is required **after** `Turbolinks.start()`, so ClientSideValidations can properly
91
+ detect `window.Turbolinks` and attach its event handlers.
92
92
 
93
93
  #### When using Sprockets ####
94
94
 
@@ -22,7 +22,7 @@ module ClientSideValidations
22
22
  end
23
23
 
24
24
  def initialize(object_name, object, template, options)
25
- super(object_name, object, template, options)
25
+ super
26
26
  @options[:validators] = { object => {} }
27
27
  end
28
28
 
@@ -45,7 +45,7 @@ module ClientSideValidations
45
45
  def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
46
46
  build_validation_options(method, options)
47
47
  options.delete(:validate)
48
- super(method, options, checked_value, unchecked_value)
48
+ super
49
49
  end
50
50
 
51
51
  %i[collection_check_boxes collection_radio_buttons].each do |method_name|
@@ -59,7 +59,7 @@ module ClientSideValidations
59
59
  def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
60
60
  build_validation_options(method, html_options.merge(name: options[:name]))
61
61
  html_options.delete(:validate)
62
- super(method, collection, value_method, text_method, options, html_options)
62
+ super
63
63
  end
64
64
 
65
65
  def fields_for(record_name, record_object = nil, fields_options = {}, &block)
@@ -69,42 +69,42 @@ module ClientSideValidations
69
69
  end
70
70
 
71
71
  fields_options[:validate] ||= @options[:validate] if @options[:validate] && !fields_options.key?(:validate)
72
- super(record_name, record_object, fields_options, &block)
72
+ super
73
73
  end
74
74
 
75
75
  def fields(scope = nil, model: nil, **options, &block)
76
76
  options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
77
- super(scope, model: model, **options, &block)
77
+ super
78
78
  end
79
79
 
80
80
  def file_field(method, options = {})
81
81
  build_validation_options(method, options)
82
82
  options.delete(:validate)
83
- super(method, options)
83
+ super
84
84
  end
85
85
 
86
86
  def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
87
87
  build_validation_options(method, html_options.merge(name: options[:name]))
88
88
  html_options.delete(:validate)
89
- super(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
89
+ super
90
90
  end
91
91
 
92
92
  def radio_button(method, tag_value, options = {})
93
93
  build_validation_options(method, options)
94
94
  options.delete(:validate)
95
- super(method, tag_value, options)
95
+ super
96
96
  end
97
97
 
98
98
  def select(method, choices = nil, options = {}, html_options = {}, &block)
99
99
  build_validation_options(method, html_options.merge(name: options[:name]))
100
100
  html_options.delete(:validate)
101
- super(method, choices, options, html_options, &block)
101
+ super
102
102
  end
103
103
 
104
104
  def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
105
105
  build_validation_options(method, html_options.merge(name: options[:name]))
106
106
  html_options.delete(:validate)
107
- super(method, priority_zones, options, html_options)
107
+ super
108
108
  end
109
109
 
110
110
  private
@@ -15,35 +15,42 @@ module ClientSideValidations
15
15
  # So we basically reimplement the whole form_for method
16
16
  raise ArgumentError, 'Missing block' unless block
17
17
 
18
- html_options = options[:html] ||= {}
18
+ options[:html] ||= {}
19
19
 
20
20
  # Moving the switch statement to another method to
21
21
  # lower complexity
22
- object, object_name = check_record(record, options)
22
+ model, object_name = check_record(record, options)
23
23
 
24
- @validators = {}
24
+ remote = options.delete(:remote)
25
25
 
26
- apply_html_options! options, html_options
27
-
28
- builder = instantiate_builder(object_name, object, options)
29
- output = capture(builder, &block)
30
- html_options[:multipart] ||= builder.multipart?
26
+ if remote && !embed_authenticity_token_in_remote_forms && options[:authenticity_token].blank?
27
+ options[:authenticity_token] = false
28
+ end
31
29
 
32
- build_bound_validators! options
30
+ options[:model] = model
31
+ options[:scope] = object_name
32
+ options[:local] = !remote
33
+ options[:skip_default_ids] = false
34
+ options[:allow_method_names_outside_object] = options.fetch(:allow_method_names_outside_object, false)
33
35
 
34
- apply_csv_html_options! html_options, options, builder
35
- html_options = html_options_for_form(options[:url] || {}, html_options)
36
- form_tag_with_body(html_options, output)
36
+ form_with(**options, &block)
37
37
  end
38
38
 
39
- def apply_form_for_options!(record, object, options)
40
- super
39
+ def apply_csv_form_for_options!(record, object, options)
41
40
  options[:html][:validate] = true if options[:validate]
41
+ options[:html][:method] ||= options[:method]
42
+
43
+ if method(:apply_form_for_options!).arity == 2
44
+ apply_form_for_options! object, options
45
+ else
46
+ apply_form_for_options! record, object, options
47
+ end
42
48
  end
43
49
 
44
50
  def fields_for(record_name, record_object = nil, options = {}, &block)
45
51
  # Order matters here. Rails mutates the `options` object
46
- output = super
52
+ builder = instantiate_builder(record_name, record_object, options)
53
+ output = capture(builder, &block)
47
54
 
48
55
  build_bound_validators! options
49
56
 
@@ -61,10 +68,10 @@ module ClientSideValidations
61
68
  raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object
62
69
 
63
70
  object_name = options[:as] || model_name_from_record_or_class(object).param_key
64
- apply_form_for_options!(record, object, options)
71
+ apply_csv_form_for_options!(record, object, options)
65
72
  end
66
73
 
67
- [object, object_name]
74
+ [record, object_name]
68
75
  end
69
76
 
70
77
  def build_bound_validators!(options)
@@ -121,19 +128,8 @@ module ClientSideValidations
121
128
  end
122
129
  end
123
130
 
124
- def apply_html_options!(options, html_options)
125
- # Turn off HTML5 validations
126
- html_options[:novalidate] = 'novalidate'
127
-
128
- html_options[:data] = options.delete(:data) if options.key?(:data)
129
- html_options[:remote] = options.delete(:remote) if options.key?(:remote)
130
- html_options[:method] = options.delete(:method) if options.key?(:method)
131
- html_options[:enforce_utf8] = options.delete(:enforce_utf8) if options.key?(:enforce_utf8)
132
- html_options[:authenticity_token] = options.delete(:authenticity_token)
133
- end
134
-
135
131
  def apply_csv_html_options!(html_options, options, builder)
136
- html_options.delete :validate
132
+ html_options.delete 'validate'
137
133
 
138
134
  csv_options = {
139
135
  html_settings: builder.client_side_form_settings(options, self),
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '19.0.0'
4
+ VERSION = '20.0.1'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.2.0 (https://github.com/DavyJonesLocker/client_side_validations)
2
+ * Client Side Validations JS - v0.3.0 (https://github.com/DavyJonesLocker/client_side_validations)
3
3
  * Copyright (c) 2021 Geremia Taglialatela, Brian Cardarella
4
4
  * Licensed under MIT (https://opensource.org/licenses/mit-license.php)
5
5
  */
@@ -17,17 +17,11 @@
17
17
  function _typeof(obj) {
18
18
  "@babel/helpers - typeof";
19
19
 
20
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
21
- _typeof = function (obj) {
22
- return typeof obj;
23
- };
24
- } else {
25
- _typeof = function (obj) {
26
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
27
- };
28
- }
29
-
30
- return _typeof(obj);
20
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
21
+ return typeof obj;
22
+ } : function (obj) {
23
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
24
+ }, _typeof(obj);
31
25
  }
32
26
 
33
27
  var ClientSideValidations = {
@@ -252,9 +246,17 @@
252
246
 
253
247
  ClientSideValidations.enablers.form(form);
254
248
  },
249
+ initializeOnEvent: function initializeOnEvent() {
250
+ if (window.Turbo != null) {
251
+ return 'turbo:load';
252
+ } else if (window.Turbolinks != null && window.Turbolinks.supported) {
253
+ return window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
254
+ }
255
+ },
255
256
  start: function start() {
256
- if (window.Turbolinks != null && window.Turbolinks.supported) {
257
- var initializeOnEvent = window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
257
+ var initializeOnEvent = ClientSideValidations.initializeOnEvent();
258
+
259
+ if (initializeOnEvent != null) {
258
260
  jQuery__default["default"](document).on(initializeOnEvent, function () {
259
261
  return jQuery__default["default"](ClientSideValidations.selectors.forms).validate();
260
262
  });
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: 19.0.0
4
+ version: 20.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-10-01 00:00:00.000000000 Z
12
+ date: 2021-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '7.0'
23
+ version: '7.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,7 +30,7 @@ dependencies:
30
30
  version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.0'
33
+ version: '7.1'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: js_regex
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -133,22 +133,16 @@ dependencies:
133
133
  name: simplecov
134
134
  requirement: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 0.18.5
139
- - - "<"
136
+ - - "~>"
140
137
  - !ruby/object:Gem::Version
141
- version: '0.22'
138
+ version: 0.21.2
142
139
  type: :development
143
140
  prerelease: false
144
141
  version_requirements: !ruby/object:Gem::Requirement
145
142
  requirements:
146
- - - ">="
147
- - !ruby/object:Gem::Version
148
- version: 0.18.5
149
- - - "<"
143
+ - - "~>"
150
144
  - !ruby/object:Gem::Version
151
- version: '0.22'
145
+ version: 0.21.2
152
146
  - !ruby/object:Gem::Dependency
153
147
  name: simplecov-lcov
154
148
  requirement: !ruby/object:Gem::Requirement
@@ -265,6 +259,7 @@ homepage: https://github.com/DavyJonesLocker/client_side_validations
265
259
  licenses:
266
260
  - MIT
267
261
  metadata:
262
+ rubygems_mfa_required: 'true'
268
263
  bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
269
264
  changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/main/CHANGELOG.md
270
265
  source_code_uri: https://github.com/DavyJonesLocker/client_side_validations