client_side_validations 16.0.3 → 16.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +12 -0
- data/lib/client_side_validations/action_view/form_with_helper.rb +4 -4
- data/lib/client_side_validations/active_model.rb +1 -1
- data/lib/client_side_validations/version.rb +1 -1
- data/vendor/assets/javascripts/rails.validations.js +5 -7
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5b98c258d8344cfcce06806a9c8e1436b1f1d218338d36d538898dbd45266f
|
4
|
+
data.tar.gz: 666821087542883e720f1f47209156aa676d1f7055889ab1e4d083bf92d94aab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec38d516eebb0e1435f7fab0eb9f8418685082581dfb8b3098ad757957929374ae8868bd084b48cdfdf95ee2b638659f5877d4edb4703196f33b212ccdc5fe35
|
7
|
+
data.tar.gz: 7a11e196aa2bff4bb91f5e856395c97620f536d94ea019fadab2e48bd9becb71694ab21103406ca9006ba22c4666d92e759c59e89e4c748ccd81f77c860cd4b3
|
data/CHANGELOG.md
CHANGED
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, &
|
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
|
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
|
/*!
|
2
|
-
* Client Side Validations JS - v0.1.
|
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
|
-
|
703
|
-
|
704
|
-
if (!validatorFunction) {
|
702
|
+
if (!validatorFunctions[validator]) {
|
705
703
|
continue;
|
706
704
|
}
|
707
705
|
|
708
|
-
if (!executeValidator(validatorFunctions,
|
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
339
|
+
rubygems_version: 3.1.2
|
340
340
|
signing_key:
|
341
341
|
specification_version: 4
|
342
342
|
summary: Client Side Validations
|