client_side_validations 4.2.1 → 4.2.2

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
  SHA1:
3
- metadata.gz: 1365fb3dbcb3cc78e1ff81c55ca7bae68562a36a
4
- data.tar.gz: 929f39e3d25915e36ee0857c28cd366d4ed66a3e
3
+ metadata.gz: 3f3a86c43a64845d17a62ceaab0fa845ebf9adac
4
+ data.tar.gz: 48bfe8322a7cfaa059e41f58951ecba876c4bba9
5
5
  SHA512:
6
- metadata.gz: 3aa912a26a995bf9863abb7e7b1384c1d071c8301088f7723c9e24b3863b5d8b6f345226874d811c82263ff16f620153155699f9a5ebca7a7331db33256bc801
7
- data.tar.gz: 7f63fd221eb2699d19ca1a4cabe5be3598fd76973f314137fdcaea9b76f704de3c2a5379fce95cb28dae2d4b3f7b182243942bc9d5b364f3e45de8d8aae8d390
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
  [![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations.svg?branch=master)](https://travis-ci.org/DavyJonesLocker/client_side_validations)
5
5
  [![Dependency Status](https://gemnasium.com/DavyJonesLocker/client_side_validations.svg)](https://gemnasium.com/DavyJonesLocker/client_side_validations)
6
6
  [![Code Climate](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/badges/gpa.svg)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations)
7
- [![Coverage Status](https://coveralls.io/repos/DavyJonesLocker/client_side_validations/badge.svg?branch=master)](https://coveralls.io/r/DavyJonesLocker/client_side_validations?branch=master)
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
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/DockYard/client_side_validations-simple_form)
74
- * [Formtastic](https://github.com/DockYard/client_side_validations-formtastic)
75
- * [Mongoid](https://github.com/DockYard/client_side_validations-mongoid)
76
- * [MongoMapper](https://github.com/DockYard/client_side_validations-mongo_mapper)
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](http://twitter.com/bcardarella)
507
+ [Brian Cardarella](https://twitter.com/bcardarella)
508
508
 
509
- [Geremia Taglialatela](http://twitter.com/gtagliala)
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](http://dockyard.com), LLC © 2012-2015
536
+ [DockYard](https://dockyard.com/), LLC © 2012-2016
537
537
 
538
- [@dockyard](http://twitter.com/dockyard)
538
+ [@dockyard](https://twitter.com/dockyard)
539
539
 
540
- [Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
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
- fail ArgumentError, 'Missing block' unless block_given?
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
- ::ClientSideValidations::Config.disabled_validators.include?(validator.kind)
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 = find_topmost_superclass(klass)
9
+ klass = find_topmost_superclass(klass)
10
10
  column = klass.columns_hash[attribute.to_s]
11
- value = type_cast_value(column, 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
- t = klass.arel_table
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
- relation = Arel::Nodes::SqlLiteral.new(sql.join(' '))
33
- !klass.where(relation).exists?
38
+ sql.join ' '
34
39
  end
35
40
 
36
41
  def self.type_cast_value(column, value)
37
- if column.respond_to?(:type_cast)
38
- column.type_cast(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
48
+
49
+ if column.limit && value.is_a?(String)
50
+ value.mb_chars[0, column.limit]
39
51
  else
40
- column.type_cast_from_database(value)
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/(\w+)\z}.match(env['PATH_INFO'])
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
- fail NotValidatable
101
+ raise NotValidatable
102
102
  end
103
103
 
104
104
  registered_orms.each do |orm|
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ClientSideValidations
3
- VERSION = '4.2.1'.freeze
3
+ VERSION = '4.2.2'.freeze
4
4
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  /*!
3
- * Client Side Validations - v4.2.1 (https://github.com/DavyJonesLocker/client_side_validations)
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.1
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-01-15 00:00:00.000000000 Z
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.10
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.10
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.36.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.36.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.1
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.1
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: []