client_side_validations 9.1.0 → 9.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/lib/client_side_validations.rb +1 -0
  4. data/lib/client_side_validations/action_view.rb +1 -0
  5. data/lib/client_side_validations/action_view/form_builder.rb +1 -0
  6. data/lib/client_side_validations/active_model.rb +13 -8
  7. data/lib/client_side_validations/active_model/absence.rb +1 -0
  8. data/lib/client_side_validations/active_model/acceptance.rb +1 -0
  9. data/lib/client_side_validations/active_model/conditionals.rb +1 -0
  10. data/lib/client_side_validations/active_model/exclusion.rb +1 -0
  11. data/lib/client_side_validations/active_model/format.rb +1 -0
  12. data/lib/client_side_validations/active_model/inclusion.rb +1 -0
  13. data/lib/client_side_validations/active_model/length.rb +11 -3
  14. data/lib/client_side_validations/active_model/numericality.rb +17 -8
  15. data/lib/client_side_validations/active_model/presence.rb +1 -0
  16. data/lib/client_side_validations/active_record.rb +1 -0
  17. data/lib/client_side_validations/active_record/uniqueness.rb +1 -0
  18. data/lib/client_side_validations/config.rb +1 -0
  19. data/lib/client_side_validations/core_ext.rb +1 -0
  20. data/lib/client_side_validations/core_ext/range.rb +1 -0
  21. data/lib/client_side_validations/core_ext/regexp.rb +1 -0
  22. data/lib/client_side_validations/engine.rb +1 -0
  23. data/lib/client_side_validations/extender.rb +1 -0
  24. data/lib/client_side_validations/files.rb +1 -0
  25. data/lib/client_side_validations/generators.rb +1 -0
  26. data/lib/client_side_validations/generators/rails_validations.rb +1 -0
  27. data/lib/client_side_validations/version.rb +1 -1
  28. data/lib/generators/client_side_validations/copy_assets_generator.rb +1 -0
  29. data/lib/generators/client_side_validations/install_generator.rb +1 -0
  30. data/lib/generators/templates/client_side_validations/initializer.rb +1 -0
  31. data/vendor/assets/javascripts/rails.validations.js +1 -1
  32. metadata +7 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90df211b4f5892467d0353fe4de921dd9424cca3
4
- data.tar.gz: 42dbbd51195d63ad7b9fb99015d197a298b9dae6
3
+ metadata.gz: 5c97aaa7e427726552ee50a3c5ef04aefb79df5d
4
+ data.tar.gz: 01ba6bb6c9d6219ee83a27cf2615c6571680f6d0
5
5
  SHA512:
6
- metadata.gz: 61fff69cc9fd41f3aae9e4840a4905ffa4dc558eda4076adfa52071b1733803edbd137fba8e5600d7117e73ff588848f186912183a3ea3965bcf19ee38fd2183
7
- data.tar.gz: 3637f5796ec4ff194f03a3bb5b1282289beff41231dbf5a54fb6a8d8dc646feace8e22b1061330913ccc3ad4469c6df712edd7bf58b6077842f87bb01849122f
6
+ metadata.gz: 21557913adad69294d2b05244bdf6b317f40cb38fe355335133b8e615b18e7c29d1828db4feb4565d1af955132b6f0c246b36821b8475bed3de791ef699eb699
7
+ data.tar.gz: 16c28cb2b54cc7ea8a961e21b25781dbb6fd14d243f2baac9e95a2bf6626b308ab78b63518e0626bd92a2815e78de04c18dc9f76320d5c055e240cbae2d7bd9a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 9.2.0 / 2017-03-23
4
+
5
+ * [ENHANCEMENT] Use Ruby 2.3's Frozen String Literal Pragma
6
+ * [ENHANCEMENT] Code cleanup
7
+ * [ENHANCEMENT] Test against Ruby 2.4.1 and Rails 5.1.0.rc1
8
+ * [ENHANCEMENT] Test against jQuery 3.2.0 and 3.2.1
9
+ * [ENHANCEMENT] Update jquery-rails runtime depenency to 4.3
10
+ * [ENHANCEMENT] Update development dependencies
11
+
3
12
  ## 9.1.0 / 2017-03-07
4
13
 
5
14
  * [ENHANCEMENT] Rails 5.1 compatibility
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'client_side_validations/config'
2
3
  require 'client_side_validations/active_model' if defined?(::ActiveModel)
3
4
  require 'client_side_validations/active_record' if defined?(::ActiveRecord)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActionView
3
4
  module Helpers
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActionView
3
4
  module Helpers
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'client_side_validations/core_ext'
2
3
  require 'client_side_validations/extender'
3
4
  require 'client_side_validations/active_model/conditionals'
@@ -31,14 +32,7 @@ module ClientSideValidations
31
32
  _validators.inject({}) do |attr_hash, attr|
32
33
  return attr_hash if [nil, :block].include?(attr[0])
33
34
 
34
- validator_hash = attr[1].each_with_object(Hash.new { |h, k| h[k] = [] }) do |validator, kind_hash|
35
- next unless can_use_for_client_side_validation?(attr[0], validator, force)
36
-
37
- client_side_hash = validator.client_side_hash(self, attr[0], extract_force_option(attr[0], force))
38
- if client_side_hash
39
- kind_hash[validator.kind] << client_side_hash.except(:on, :if, :unless)
40
- end
41
- end
35
+ validator_hash = validator_hash_for(attr, force)
42
36
 
43
37
  if validator_hash.present?
44
38
  attr_hash.merge!(attr[0] => validator_hash)
@@ -50,6 +44,17 @@ module ClientSideValidations
50
44
 
51
45
  private
52
46
 
47
+ def validator_hash_for(attr, force)
48
+ attr[1].each_with_object(Hash.new { |h, k| h[k] = [] }) do |validator, kind_hash|
49
+ next unless can_use_for_client_side_validation?(attr[0], validator, force)
50
+
51
+ client_side_hash = validator.client_side_hash(self, attr[0], extract_force_option(attr[0], force))
52
+ if client_side_hash
53
+ kind_hash[validator.kind] << client_side_hash.except(:on, :if, :unless)
54
+ end
55
+ end
56
+ end
57
+
53
58
  def extract_force_option(attr, force)
54
59
  case force
55
60
  when FalseClass, TrueClass, NilClass
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Absence
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Acceptance
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Conditionals
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Exclusion
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Format
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Inclusion
@@ -1,11 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Length
4
5
  def client_side_hash(model, attribute, _force = nil)
5
6
  options = self.options.dup
6
- hash = { messages: {} }
7
- hash[:js_tokenizer] = options[:js_tokenizer] if options[:js_tokenizer]
8
- hash[:allow_blank] = true if options[:allow_blank]
7
+ hash = options_hash(options)
9
8
 
10
9
  self.class::MESSAGES.each do |option, message_type|
11
10
  count = options[option]
@@ -21,6 +20,15 @@ module ClientSideValidations
21
20
 
22
21
  hash
23
22
  end
23
+
24
+ private
25
+
26
+ def options_hash(options)
27
+ hash = { messages: {} }
28
+ hash[:js_tokenizer] = options[:js_tokenizer] if options[:js_tokenizer]
29
+ hash[:allow_blank] = true if options[:allow_blank]
30
+ hash
31
+ end
24
32
  end
25
33
  end
26
34
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Numericality
@@ -9,14 +10,7 @@ module ClientSideValidations
9
10
 
10
11
  def client_side_hash(model, attribute, force = nil)
11
12
  options = self.options.dup
12
- hash = { messages: { numericality: model.errors.generate_message(attribute, :not_a_number, options) } }
13
-
14
- if options[:only_integer]
15
- hash[:messages][:only_integer] = model.errors.generate_message(attribute, :not_an_integer, options)
16
- hash[:only_integer] = true
17
- end
18
-
19
- hash[:allow_blank] = true if options[:allow_nil] || options[:allow_blank]
13
+ hash = options_hash(model, attribute, options)
20
14
 
21
15
  @@option_map.each do |option, message_type|
22
16
  count = options[option]
@@ -35,6 +29,21 @@ module ClientSideValidations
35
29
 
36
30
  hash
37
31
  end
32
+
33
+ private
34
+
35
+ def options_hash(model, attribute, options)
36
+ hash = { messages: { numericality: model.errors.generate_message(attribute, :not_a_number, options) } }
37
+
38
+ if options[:only_integer]
39
+ hash[:messages][:only_integer] = model.errors.generate_message(attribute, :not_an_integer, options)
40
+ hash[:only_integer] = true
41
+ end
42
+
43
+ hash[:allow_blank] = true if options[:allow_nil] || options[:allow_blank]
44
+
45
+ hash
46
+ end
38
47
  end
39
48
  end
40
49
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveModel
3
4
  module Presence
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'client_side_validations/active_model'
2
3
  require 'client_side_validations/extender'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module ActiveRecord
3
4
  module Uniqueness
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module Config
3
4
  class << self
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'active_support/json'
2
3
  require 'client_side_validations/core_ext/range'
3
4
  require 'client_side_validations/core_ext/regexp'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Range
2
3
  def as_json(*)
3
4
  [first, last]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'js_regex'
2
3
 
3
4
  class Regexp
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  class Engine < ::Rails::Engine
3
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module Extender
3
4
  module_function
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This is only used by dependant libraries that need to find the files
2
3
 
3
4
  module ClientSideValidations
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module Generators
3
4
  @@assets = []
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module Generators
3
4
  class RailsValidations
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ClientSideValidations
3
- VERSION = '9.1.0'.freeze
3
+ VERSION = '9.2.0'.freeze
4
4
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module ClientSideValidations
2
3
  module Generators
3
4
  class CopyAssetsGenerator < Rails::Generators::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'generators/client_side_validations/copy_assets_generator'
2
3
 
3
4
  module ClientSideValidations
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # ClientSideValidations Initializer
2
3
 
3
4
  # Disabled validators
@@ -1,6 +1,6 @@
1
1
 
2
2
  /*!
3
- * Client Side Validations - v9.1.0 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Client Side Validations - v9.2.0 (https://github.com/DavyJonesLocker/client_side_validations)
4
4
  * Copyright (c) 2017 Geremia Taglialatela, Brian Cardarella
5
5
  * Licensed under MIT (http://opensource.org/licenses/mit-license.php)
6
6
  */
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: 9.1.0
4
+ version: 9.2.0
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: 2017-03-07 00:00:00.000000000 Z
12
+ date: 2017-03-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -37,14 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.2'
40
+ version: '4.3'
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.2'
47
+ version: '4.3'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: js_regex
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -205,14 +205,14 @@ dependencies:
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: 2.0.0.rc1
208
+ version: 2.0.0.rc2
209
209
  type: :development
210
210
  prerelease: false
211
211
  version_requirements: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: 2.0.0.rc1
215
+ version: 2.0.0.rc2
216
216
  - !ruby/object:Gem::Dependency
217
217
  name: shotgun
218
218
  requirement: !ruby/object:Gem::Requirement
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  version: '0'
317
317
  requirements: []
318
318
  rubyforge_project:
319
- rubygems_version: 2.6.9
319
+ rubygems_version: 2.6.11
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: Client Side Validations