client_side_validations 4.2.1 → 4.2.2
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/HISTORY.md +1 -0
- data/README.md +10 -10
- data/lib/client_side_validations/action_view/form_helper.rb +1 -1
- data/lib/client_side_validations/active_model.rb +2 -1
- data/lib/client_side_validations/active_record/middleware.rb +21 -9
- data/lib/client_side_validations/middleware.rb +2 -2
- data/lib/client_side_validations/version.rb +1 -1
- data/vendor/assets/javascripts/rails.validations.js +2 -2
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3a86c43a64845d17a62ceaab0fa845ebf9adac
|
4
|
+
data.tar.gz: 48bfe8322a7cfaa059e41f58951ecba876c4bba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b516873173fc70b07c3ba6e01101ce19ebd517a71e33c241fa8a8479a261fcb254f2eb96827a563b2726f429459d2376fe88767349748df5b661e40ff9ba336
|
7
|
+
data.tar.gz: 51a23f2d82686d89ed27840bf8742cf7db2beebb3e3576bc7b4e388e459eb67ef631f51c61b843176a36b8db69aadd3c735edc2cb1e9c4f3135ab7257ef0ec5d
|
data/HISTORY.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
## Version 4.2
|
4
4
|
|
5
|
+
* [v4.2.2](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.1...v4.2.2)
|
5
6
|
* [v4.2.1](https://github.com/DavyJonesLocker/client_side_validations/compare/v4.2.0...v4.2.1)
|
6
7
|
* [v4.2.0](https://github.com/DavyJonesLocker/client_side_validations/compare/v3.2.6...v4.2.0)
|
7
8
|
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/DavyJonesLocker/client_side_validations)
|
5
5
|
[](https://gemnasium.com/DavyJonesLocker/client_side_validations)
|
6
6
|
[](https://codeclimate.com/github/DavyJonesLocker/client_side_validations)
|
7
|
-
[](https://coveralls.io/
|
7
|
+
[](https://coveralls.io/github/DavyJonesLocker/client_side_validations?branch=master)
|
8
8
|
|
9
9
|
`ClientSideValidations` made easy for your Rails 4 applications!
|
10
10
|
|
@@ -70,10 +70,10 @@ There is additional support for other `ActiveModel` based ORMs and other
|
|
70
70
|
Rails `FormBuilders`. Please see the [Plugin wiki page](https://github.com/DavyJonesLocker/client_side_validations/wiki/Plugins)
|
71
71
|
(feel free to add your own)
|
72
72
|
|
73
|
-
* [SimpleForm](https://github.com/
|
74
|
-
* [Formtastic](https://github.com/
|
75
|
-
* [Mongoid](https://github.com/
|
76
|
-
* [MongoMapper](https://github.com/
|
73
|
+
* [SimpleForm](https://github.com/DavyJonesLocker/client_side_validations-simple_form)
|
74
|
+
* [Formtastic](https://github.com/DavyJonesLocker/client_side_validations-formtastic)
|
75
|
+
* [Mongoid](https://github.com/DavyJonesLocker/client_side_validations-mongoid)
|
76
|
+
* [MongoMapper](https://github.com/DavyJonesLocker/client_side_validations-mongo_mapper)
|
77
77
|
|
78
78
|
## Usage ##
|
79
79
|
|
@@ -504,9 +504,9 @@ Note that the `FormBuilder` will automatically skip building validators that are
|
|
504
504
|
|
505
505
|
## Authors ##
|
506
506
|
|
507
|
-
[Brian Cardarella](
|
507
|
+
[Brian Cardarella](https://twitter.com/bcardarella)
|
508
508
|
|
509
|
-
[Geremia Taglialatela](
|
509
|
+
[Geremia Taglialatela](https://twitter.com/gtagliala)
|
510
510
|
|
511
511
|
[We are very thankful for the many contributors](https://github.com/DavyJonesLocker/client_side_validations/graphs/contributors)
|
512
512
|
|
@@ -533,8 +533,8 @@ on how to properly submit issues and pull requests.
|
|
533
533
|
|
534
534
|
## Legal ##
|
535
535
|
|
536
|
-
[DockYard](
|
536
|
+
[DockYard](https://dockyard.com/), LLC © 2012-2016
|
537
537
|
|
538
|
-
[@dockyard](
|
538
|
+
[@dockyard](https://twitter.com/dockyard)
|
539
539
|
|
540
|
-
[Licensed under the MIT license](
|
540
|
+
[Licensed under the MIT license](https://opensource.org/licenses/mit-license.php)
|
@@ -7,7 +7,7 @@ module ClientSideValidations
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def form_for(record, options = {}, &block)
|
10
|
-
|
10
|
+
raise ArgumentError, 'Missing block' unless block_given?
|
11
11
|
if options[:validate]
|
12
12
|
|
13
13
|
# Always turn off HTML5 Validations
|
@@ -88,6 +88,7 @@ module ClientSideValidations
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def validator_turned_off?(attr, validator, force)
|
91
|
+
return true if ::ClientSideValidations::Config.disabled_validators.include?(validator.kind)
|
91
92
|
case force
|
92
93
|
when FalseClass
|
93
94
|
true
|
@@ -101,7 +102,7 @@ module ClientSideValidations
|
|
101
102
|
false
|
102
103
|
end
|
103
104
|
else
|
104
|
-
|
105
|
+
false
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
@@ -6,14 +6,20 @@ module ClientSideValidations
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.unique?(klass, attribute, value, params)
|
9
|
-
klass
|
9
|
+
klass = find_topmost_superclass(klass)
|
10
10
|
column = klass.columns_hash[attribute.to_s]
|
11
|
-
value
|
12
|
-
value = column.limit ? value.to_s.mb_chars[0, column.limit] : value.to_s if value.is_a?(String)
|
11
|
+
value = type_cast_value(column, value)
|
13
12
|
|
14
|
-
|
13
|
+
sql = sql_statement(klass, attribute, value, params)
|
14
|
+
relation = Arel::Nodes::SqlLiteral.new(sql)
|
15
15
|
|
16
|
+
!klass.where(relation).exists?
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.sql_statement(klass, attribute, value, params)
|
16
20
|
sql = []
|
21
|
+
t = klass.arel_table
|
22
|
+
|
17
23
|
if params[:case_sensitive] == 'true'
|
18
24
|
sql << 'BINARY' if t.engine.connection.adapter_name =~ /^mysql/i
|
19
25
|
sql << t[attribute].eq(value).to_sql
|
@@ -29,15 +35,21 @@ module ClientSideValidations
|
|
29
35
|
sql << "AND #{t[scope_attribute].eq(scope_value).to_sql}"
|
30
36
|
end
|
31
37
|
|
32
|
-
|
33
|
-
!klass.where(relation).exists?
|
38
|
+
sql.join ' '
|
34
39
|
end
|
35
40
|
|
36
41
|
def self.type_cast_value(column, value)
|
37
|
-
|
38
|
-
column.type_cast
|
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
|
48
|
+
|
49
|
+
if column.limit && value.is_a?(String)
|
50
|
+
value.mb_chars[0, column.limit]
|
39
51
|
else
|
40
|
-
|
52
|
+
value
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
@@ -8,7 +8,7 @@ module ClientSideValidations
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(env)
|
11
|
-
matches = %r{\A/validators
|
11
|
+
matches = %r{\A/?#{ClientSideValidations::Config.root_path}/validators\/(\w+)\z}.match(env['PATH_INFO'])
|
12
12
|
if matches
|
13
13
|
process_request(matches.captures.first, env)
|
14
14
|
else
|
@@ -98,7 +98,7 @@ module ClientSideValidations
|
|
98
98
|
middleware_class = nil
|
99
99
|
|
100
100
|
unless Array.wrap(klass._validators[attribute.to_sym]).find { |v| v.kind == :uniqueness }
|
101
|
-
|
101
|
+
raise NotValidatable
|
102
102
|
end
|
103
103
|
|
104
104
|
registered_orms.each do |orm|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
/*!
|
3
|
-
* Client Side Validations - v4.2.
|
4
|
-
* Copyright (c) 2016 Brian Cardarella
|
3
|
+
* Client Side Validations - v4.2.2 (https://github.com/DavyJonesLocker/client_side_validations)
|
4
|
+
* Copyright (c) 2016 Geremia Taglialatela, Brian Cardarella
|
5
5
|
* Licensed under MIT (http://opensource.org/licenses/mit-license.php)
|
6
6
|
*/
|
7
7
|
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client_side_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Geremia Taglialatela
|
7
8
|
- Brian Cardarella
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-02-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -90,14 +91,14 @@ dependencies:
|
|
90
91
|
requirements:
|
91
92
|
- - "~>"
|
92
93
|
- !ruby/object:Gem::Version
|
93
|
-
version: 0.8.
|
94
|
+
version: 0.8.12
|
94
95
|
type: :development
|
95
96
|
prerelease: false
|
96
97
|
version_requirements: !ruby/object:Gem::Requirement
|
97
98
|
requirements:
|
98
99
|
- - "~>"
|
99
100
|
- !ruby/object:Gem::Version
|
100
|
-
version: 0.8.
|
101
|
+
version: 0.8.12
|
101
102
|
- !ruby/object:Gem::Dependency
|
102
103
|
name: m
|
103
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,28 +153,28 @@ dependencies:
|
|
152
153
|
requirements:
|
153
154
|
- - "~>"
|
154
155
|
- !ruby/object:Gem::Version
|
155
|
-
version: 0.
|
156
|
+
version: 0.37.2
|
156
157
|
type: :development
|
157
158
|
prerelease: false
|
158
159
|
version_requirements: !ruby/object:Gem::Requirement
|
159
160
|
requirements:
|
160
161
|
- - "~>"
|
161
162
|
- !ruby/object:Gem::Version
|
162
|
-
version: 0.
|
163
|
+
version: 0.37.2
|
163
164
|
- !ruby/object:Gem::Dependency
|
164
165
|
name: simplecov
|
165
166
|
requirement: !ruby/object:Gem::Requirement
|
166
167
|
requirements:
|
167
168
|
- - "~>"
|
168
169
|
- !ruby/object:Gem::Version
|
169
|
-
version: 0.11.
|
170
|
+
version: 0.11.2
|
170
171
|
type: :development
|
171
172
|
prerelease: false
|
172
173
|
version_requirements: !ruby/object:Gem::Requirement
|
173
174
|
requirements:
|
174
175
|
- - "~>"
|
175
176
|
- !ruby/object:Gem::Version
|
176
|
-
version: 0.11.
|
177
|
+
version: 0.11.2
|
177
178
|
- !ruby/object:Gem::Dependency
|
178
179
|
name: sqlite3
|
179
180
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,6 +275,7 @@ dependencies:
|
|
274
275
|
version: '2.4'
|
275
276
|
description: Client Side Validations made easy for your Rails 4 applications
|
276
277
|
email:
|
278
|
+
- tagliala.dev@gmail.com
|
277
279
|
- bcardarella@gmail.com
|
278
280
|
executables: []
|
279
281
|
extensions: []
|