client_side_validations 16.0.3 → 16.0.4

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
  SHA256:
3
- metadata.gz: 9893d8ea2559c48246a18e75f05032a3503708a7dbda3be04a822d6ca743e439
4
- data.tar.gz: 6069c83656296d9811dadab566f89e019d626518f4612c920ab8ed7073b8c4f1
3
+ metadata.gz: 7a5b98c258d8344cfcce06806a9c8e1436b1f1d218338d36d538898dbd45266f
4
+ data.tar.gz: 666821087542883e720f1f47209156aa676d1f7055889ab1e4d083bf92d94aab
5
5
  SHA512:
6
- metadata.gz: 14988e0e4674b7870643fd56fc12eed129e7937f1b79a99afa62b5bc9516d40c7b407944738e0f80bfdfafcd72fecc2ce480f0d193e41152277bf9b3b9174c84
7
- data.tar.gz: 6a56df2ab28a446ee19b0fc42d30743c4d72e8def54b693c9c9a82d1c1309a67350745d0f824f55fd28cf80eda26c565c69fe9afb72faee1fd89619fd7f4d6bf
6
+ metadata.gz: ec38d516eebb0e1435f7fab0eb9f8418685082581dfb8b3098ad757957929374ae8868bd084b48cdfdf95ee2b638659f5877d4edb4703196f33b212ccdc5fe35
7
+ data.tar.gz: 7a11e196aa2bff4bb91f5e856395c97620f536d94ea019fadab2e48bd9becb71694ab21103406ca9006ba22c4666d92e759c59e89e4c748ccd81f77c860cd4b3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 16.1.0 / 2019-12-25
4
+
5
+ * [FEATURE] Ruby 2.7 support
6
+ * [ENHANCEMENT] Update development dependencies
7
+
3
8
  ## 16.0.3 / 2019-10-06
4
9
 
5
10
  * [BUGFIX] Fix `validators.all` function
data/README.md CHANGED
@@ -153,6 +153,18 @@ when used together with Rails >= 5.1. The syntax is the same as `form_for`:
153
153
  **Note:** ClientSideValidations requires `id` attributes on form fields to
154
154
  work, so it will force `form_with` to generate ids.
155
155
 
156
+ ## Validators order ##
157
+
158
+ By default, ClientSideValidations will perform the validations in the same order
159
+ specified in your models. In other words, if you want to validate the format
160
+ of an email field before its presence, you can use the following:
161
+
162
+ ```rb
163
+ class User < ApplicationRecord
164
+ validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }, presence: true
165
+ end
166
+ ```
167
+
156
168
  ## Conditional Validators ##
157
169
 
158
170
  By default conditional validators are not evaluated and passed to the client.
@@ -15,7 +15,7 @@ module ClientSideValidations
15
15
  if block_given?
16
16
  form_tag_with_validators scope, model, options, url, &block
17
17
  else
18
- html_options = html_options_for_form_with(url, model, options)
18
+ html_options = html_options_for_form_with(url, model, **options)
19
19
  form_tag_html(html_options)
20
20
  end
21
21
  end
@@ -31,16 +31,16 @@ module ClientSideValidations
31
31
  [url, model, scope]
32
32
  end
33
33
 
34
- def form_tag_with_validators(scope, model, options, url)
34
+ def form_tag_with_validators(scope, model, options, url, &block)
35
35
  @validators = {}
36
36
 
37
37
  builder = instantiate_builder(scope, model, options)
38
- output = capture(builder, &Proc.new)
38
+ output = capture(builder, &block)
39
39
  options[:multipart] ||= builder.multipart?
40
40
 
41
41
  build_bound_validators! options
42
42
 
43
- html_options = html_options_for_form_with(url, model, options)
43
+ html_options = html_options_for_form_with(url, model, **options)
44
44
 
45
45
  if model
46
46
  html_options[:novalidate] ||= 'novalidate'
@@ -91,7 +91,7 @@ module ClientSideValidations
91
91
  end
92
92
 
93
93
  def will_save_change?(options)
94
- options =~ /changed\?/ || options =~ /will_save_change_to/
94
+ options.is_a?(Symbol) && (options.to_s.ends_with?('changed?') || options.to_s.starts_with?('will_save_change_to'))
95
95
  end
96
96
 
97
97
  def check_conditionals(attr, validator, force)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '16.0.3'
4
+ VERSION = '16.0.4'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.0 (https://github.com/DavyJonesLocker/client_side_validations)
2
+ * Client Side Validations JS - v0.1.1 (https://github.com/DavyJonesLocker/client_side_validations)
3
3
  * Copyright (c) 2019 Geremia Taglialatela, Brian Cardarella
4
4
  * Licensed under MIT (https://opensource.org/licenses/mit-license.php)
5
5
  */
@@ -8,7 +8,7 @@
8
8
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
9
9
  typeof define === 'function' && define.amd ? define(['jquery'], factory) :
10
10
  (global = global || self, global.ClientSideValidations = factory(global.$));
11
- }(this, function ($) { 'use strict';
11
+ }(this, (function ($) { 'use strict';
12
12
 
13
13
  $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
14
14
 
@@ -699,13 +699,11 @@
699
699
 
700
700
  var executeValidators = function executeValidators(validatorFunctions, element, validators) {
701
701
  for (var validator in validators) {
702
- var validatorFunction = validatorFunctions[validator];
703
-
704
- if (!validatorFunction) {
702
+ if (!validatorFunctions[validator]) {
705
703
  continue;
706
704
  }
707
705
 
708
- if (!executeValidator(validatorFunctions, validatorFunction, validators[validator], element)) {
706
+ if (!executeValidator(validatorFunctions, validatorFunctions[validator], validators[validator], element)) {
709
707
  return false;
710
708
  }
711
709
  }
@@ -767,4 +765,4 @@
767
765
 
768
766
  return ClientSideValidations;
769
767
 
770
- }));
768
+ })));
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: 16.0.3
4
+ version: 16.0.4
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: 2019-10-06 00:00:00.000000000 Z
12
+ date: 2019-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 0.13.2
102
+ version: 0.14.0
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 0.13.2
109
+ version: 0.14.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: m
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -127,28 +127,28 @@ dependencies:
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '5.12'
130
+ version: '5.13'
131
131
  type: :development
132
132
  prerelease: false
133
133
  version_requirements: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '5.12'
137
+ version: '5.13'
138
138
  - !ruby/object:Gem::Dependency
139
139
  name: mocha
140
140
  requirement: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '1.9'
144
+ version: '1.11'
145
145
  type: :development
146
146
  prerelease: false
147
147
  version_requirements: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '1.9'
151
+ version: '1.11'
152
152
  - !ruby/object:Gem::Dependency
153
153
  name: rake
154
154
  requirement: !ruby/object:Gem::Requirement
@@ -169,14 +169,14 @@ dependencies:
169
169
  requirements:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: 0.75.0
172
+ version: 0.78.0
173
173
  type: :development
174
174
  prerelease: false
175
175
  version_requirements: !ruby/object:Gem::Requirement
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: 0.75.0
179
+ version: 0.78.0
180
180
  - !ruby/object:Gem::Dependency
181
181
  name: rubocop-performance
182
182
  requirement: !ruby/object:Gem::Requirement
@@ -197,14 +197,14 @@ dependencies:
197
197
  requirements:
198
198
  - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '2.3'
200
+ version: '2.4'
201
201
  type: :development
202
202
  prerelease: false
203
203
  version_requirements: !ruby/object:Gem::Requirement
204
204
  requirements:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '2.3'
207
+ version: '2.4'
208
208
  - !ruby/object:Gem::Dependency
209
209
  name: simplecov
210
210
  requirement: !ruby/object:Gem::Requirement
@@ -225,14 +225,14 @@ dependencies:
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '1.3'
228
+ version: '1.4'
229
229
  type: :development
230
230
  prerelease: false
231
231
  version_requirements: !ruby/object:Gem::Requirement
232
232
  requirements:
233
233
  - - "~>"
234
234
  - !ruby/object:Gem::Version
235
- version: '1.3'
235
+ version: '1.4'
236
236
  - !ruby/object:Gem::Dependency
237
237
  name: shotgun
238
238
  requirement: !ruby/object:Gem::Requirement
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  - !ruby/object:Gem::Version
337
337
  version: '0'
338
338
  requirements: []
339
- rubygems_version: 3.0.6
339
+ rubygems_version: 3.1.2
340
340
  signing_key:
341
341
  specification_version: 4
342
342
  summary: Client Side Validations