client_side_validations 16.2.0 → 18.0.0

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: 5320f254fa2dd8fd48006b2489a2a13319afbff7c89015011d93dab5ea4634f2
4
- data.tar.gz: 111dc6f36d987e5cde360d75baa482e658b3e25145530b49c02a661bc47e40b5
3
+ metadata.gz: 8dc15936a8857d5311c69d449ec11b43d4e3aa5f1d9aead78c65e9066f71cbf4
4
+ data.tar.gz: 36cca6a91972fdd818bda21b9ea3b9cb85f196c88e197872389df21ca090701d
5
5
  SHA512:
6
- metadata.gz: 7006a5df563bdd1885dcf2c1afd431f25dbf80bf15a96d9e3889f67c5039d634fec9fe5c92ac2d02a3f38a4df1cb34c573971c480702728b61c5be3b493e3a50
7
- data.tar.gz: 8a2288c4e11f543c923ae3a6d76d6c715eea57140ad172916d4bee2b0c960b11cdfdc64436c3df78e2584420a1688b1fed9e371f864fb441d8e7c0027b1285d3
6
+ metadata.gz: 1b4d6d4eb7b3e3e79bd2cfa4823a7de7802a2bbd0bbba6f0a8e65862e03fff70f7cdb75fec64e22d7b689b1f9ea2c3edf952cc95c6552c6274f70da126f988eb
7
+ data.tar.gz: 9efe40881ffc2cbb86b1d02de44318807da27d58859033e0d6a4231c4f3c33c89d8dace2f99f0541b68380279cbff658003895e5460ebdf526b72ec721cbf044
data/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 18.0.0 / 2021-02-13
4
+
5
+ * [FEATURE] Add Rails 7.0.pre compatibility
6
+ * [ENHANCEMENT] Default branch is now `main` **POSSIBLE BREAKING CHANGE!**
7
+ * [ENHANCEMENT] Update QUnit to 2.14.0
8
+ * [ENHANCEMENT] Update development dependencies
9
+
10
+ ## 17.2.0 / 2020-11-03
11
+
12
+ * [FEATURE] Add Rails 6.1.0.rc1 compatibility
13
+ * [ENHANCEMENT] Update development dependencies
14
+
15
+ ## 17.1.1 / 2020-10-31
16
+
17
+ * [ENHANCEMENT] Minor code cleanup
18
+ * [ENHANCEMENT] Update development dependencies
19
+
20
+ ## 17.1.0 / 2020-10-10
21
+
22
+ * [FEATURE] Allow Ruby 3.0.0
23
+ * [ENHANCEMENT] Test against latest Ruby 2.7.2
24
+ * [ENHANCEMENT] Update QUnit to 2.11.3
25
+ * [ENHANCEMENT] Update development dependencies
26
+
27
+ ## 17.0.0 / 2020-05-16
28
+
29
+ * [FEATURE] Drop Ruby 2.3 support
30
+ * [FEATURE] Do not require `jquery-rails` gem ([#785](https://github.com/DavyJonesLocker/client_side_validations/pull/785))
31
+ * [FEATURE] Add support for many association validations ([#783](https://github.com/DavyJonesLocker/client_side_validations/pull/783))
32
+ * [BUGFIX] Fix Rails generators ([#786](https://github.com/DavyJonesLocker/client_side_validations/pull/786))
33
+ * [BUGFIX] Do not validate dynamically disabled inputs ([#789](https://github.com/DavyJonesLocker/client_side_validations/pull/789))
34
+ * [BUGFIX] Fix removal of error messages ([#790](https://github.com/DavyJonesLocker/client_side_validations/pull/790))
35
+ * [ENHANCEMENT] Test against jQuery 3.5.1
36
+
3
37
  ## 16.2.0 / 2020-04-10
4
38
 
5
39
  * [FEATURE] Add jQuery 3.5.0 compatibility ([#779](https://github.com/DavyJonesLocker/client_side_validations/pull/779))
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Geremia Taglialatela, Brian Cardarella
3
+ Copyright (c) 2021 Geremia Taglialatela, Brian Cardarella
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,11 +2,13 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/client_side_validations.svg)](https://badge.fury.io/rb/client_side_validations)
4
4
  [![npm version](https://badge.fury.io/js/%40client-side-validations%2Fclient-side-validations.svg)](https://badge.fury.io/js/%40client-side-validations%2Fclient-side-validations)
5
- [![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations.svg?branch=master)](https://travis-ci.org/DavyJonesLocker/client_side_validations)
5
+ [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=client_side_validations&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=client_side_validations&package-manager=bundler&version-scheme=semver)
6
+ [![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations.svg?branch=main)](https://travis-ci.org/DavyJonesLocker/client_side_validations)
6
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/9f9e8bb6edc92615f34e/maintainability)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/maintainability)
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
+ [![Coverage Status](https://coveralls.io/repos/github/DavyJonesLocker/client_side_validations/badge.svg?branch=main)](https://coveralls.io/github/DavyJonesLocker/client_side_validations?branch=main)
8
9
 
9
- `ClientSideValidations` made easy for your Rails 5.x / Rails 6.0 applications!
10
+
11
+ `ClientSideValidations` made easy for your Rails 5.x / Rails 6.x applications!
10
12
 
11
13
  ## Project Goals ##
12
14
 
@@ -90,9 +92,26 @@ attach its event handlers.
90
92
 
91
93
  #### When using Sprockets ####
92
94
 
93
- Make sure that you are requiring jQuery.
95
+ Since ClientSideValidations can also be used via webpacker, it does not require
96
+ by default `jquery-rails` gem.
97
+
98
+ Make sure that `jquery-rails` is part of your bundled gems and `application.js`,
99
+ otherwise add:
100
+
101
+ ```ruby
102
+ gem 'jquery-rails', '~> 4.3'
103
+ ```
104
+
105
+ to your `Gemfile`, run `bundle`, and add
106
+
107
+ ```js
108
+ //= require jquery
109
+ ```
110
+
111
+ to your `app/assets/javascripts/application.js` file.
94
112
 
95
- Add the following to your `app/assets/javascripts/application.js` file.
113
+ Then, add the following to your `app/assets/javascripts/application.js` file
114
+ after `//= require jquery`.
96
115
 
97
116
  ```js
98
117
  //= require rails.validations
@@ -115,11 +134,10 @@ Note: If you run `copy_assets`, you will need to run it again each time you upda
115
134
  The initializer includes a commented out `ActionView::Base.field_error_proc`.
116
135
  Uncomment this to render your error messages inline with the input fields.
117
136
 
118
- I recommend you not use a solution similar to `error_messages_for`. Client
119
- Side Validations is never going to support rendering this type of error
120
- rendering. If you want to maintain consistency between the client side
121
- rendered validation error messages and the server side rendered
122
- validation error messages please use what is in
137
+ I recommend you to not use a solution similar to `error_messages_for`. Client
138
+ Side Validations does not support this type of error rendering. If you want to
139
+ maintain consistency between the client side rendered validation error messages
140
+ and the server side rendered validation error messages please use what is in
123
141
  `config/initializers/client_side_validations.rb`
124
142
 
125
143
  ## Plugins ##
@@ -520,12 +538,12 @@ This gem follows [Semantic Versioning](https://semver.org)
520
538
  ## Want to help? ##
521
539
 
522
540
  Please do! We are always looking to improve this gem. Please see our
523
- [Contribution Guidelines](https://github.com/DavyJonesLocker/client_side_validations/blob/master/CONTRIBUTING.md)
541
+ [Contribution Guidelines](https://github.com/DavyJonesLocker/client_side_validations/blob/main/CONTRIBUTING.md)
524
542
  on how to properly submit issues and pull requests.
525
543
 
526
544
  ## Legal ##
527
545
 
528
- [DockYard](https://dockyard.com/), LLC © 2012-2019
546
+ [DockYard](https://dockyard.com/), LLC © 2012-2021
529
547
 
530
548
  [@dockyard](https://twitter.com/dockyard)
531
549
 
@@ -7,21 +7,25 @@ module ClientSideValidations
7
7
  def self.prepended(base)
8
8
  (base.field_helpers - %i[label check_box radio_button fields_for hidden_field file_field]).each do |selector|
9
9
  base.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
- def #{selector}(method, options = {})
11
- build_validation_options(method, options)
12
- options.delete(:validate)
13
-
14
- # Cannot call super here, override the whole method
15
- @template.send( # @template.send(
16
- #{selector.inspect}, # "text_field",
17
- @object_name, # @object_name,
18
- method, # method,
19
- objectify_options(options)) # objectify_options(options))
20
- end
10
+ # Cannot call super here, rewrite all
11
+ def #{selector}(method, options = {}) # def text_field(method, options = {})
12
+ build_validation_options(method, options) # build_validation_options(method, options)
13
+ options.delete(:validate) # options.delete(:validate)
14
+ @template.send( # @template.send(
15
+ #{selector.inspect}, # "text_field",
16
+ @object_name, # @object_name,
17
+ method, # method,
18
+ objectify_options(options)) # objectify_options(options))
19
+ end # end
21
20
  RUBY_EVAL
22
21
  end
23
22
  end
24
23
 
24
+ def initialize(object_name, object, template, options)
25
+ super(object_name, object, template, options)
26
+ @options[:validators] = { object => {} }
27
+ end
28
+
25
29
  def client_side_form_settings(_options, form_helper)
26
30
  {
27
31
  type: self.class.to_s,
@@ -38,9 +42,24 @@ module ClientSideValidations
38
42
  nil
39
43
  end
40
44
 
41
- def initialize(object_name, object, template, options)
42
- super(object_name, object, template, options)
43
- @options[:validators] = { object => {} }
45
+ def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
46
+ build_validation_options(method, options)
47
+ options.delete(:validate)
48
+ super(method, options, checked_value, unchecked_value)
49
+ end
50
+
51
+ %i[collection_check_boxes collection_radio_buttons].each do |method_name|
52
+ define_method method_name do |method, collection, value_method, text_method, options = {}, html_options = {}, &block|
53
+ build_validation_options(method, html_options.merge(name: options[:name]))
54
+ html_options.delete(:validate)
55
+ super(method, collection, value_method, text_method, options, html_options, &block)
56
+ end
57
+ end
58
+
59
+ def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
60
+ build_validation_options(method, html_options.merge(name: options[:name]))
61
+ html_options.delete(:validate)
62
+ super(method, collection, value_method, text_method, options, html_options)
44
63
  end
45
64
 
46
65
  def fields_for(record_name, record_object = nil, fields_options = {}, &block)
@@ -53,10 +72,16 @@ module ClientSideValidations
53
72
  super(record_name, record_object, fields_options, &block)
54
73
  end
55
74
 
56
- def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
75
+ def file_field(method, options = {})
57
76
  build_validation_options(method, options)
58
77
  options.delete(:validate)
59
- super(method, options, checked_value, unchecked_value)
78
+ super(method, options)
79
+ end
80
+
81
+ def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
82
+ build_validation_options(method, html_options.merge(name: options[:name]))
83
+ html_options.delete(:validate)
84
+ super(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
60
85
  end
61
86
 
62
87
  def radio_button(method, tag_value, options = {})
@@ -71,38 +96,12 @@ module ClientSideValidations
71
96
  super(method, choices, options, html_options, &block)
72
97
  end
73
98
 
74
- def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
75
- build_validation_options(method, html_options.merge(name: options[:name]))
76
- html_options.delete(:validate)
77
- super(method, collection, value_method, text_method, options, html_options)
78
- end
79
-
80
- %i[collection_check_boxes collection_radio_buttons].each do |method_name|
81
- define_method method_name do |method, collection, value_method, text_method, options = {}, html_options = {}, &block|
82
- build_validation_options(method, html_options.merge(name: options[:name]))
83
- html_options.delete(:validate)
84
- super(method, collection, value_method, text_method, options, html_options, &block)
85
- end
86
- end
87
-
88
- def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
89
- build_validation_options(method, html_options.merge(name: options[:name]))
90
- html_options.delete(:validate)
91
- super(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
92
- end
93
-
94
99
  def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
95
100
  build_validation_options(method, html_options.merge(name: options[:name]))
96
101
  html_options.delete(:validate)
97
102
  super(method, priority_zones, options, html_options)
98
103
  end
99
104
 
100
- def file_field(method, options = {})
101
- build_validation_options(method, options)
102
- options.delete(:validate)
103
- super(method, options)
104
- end
105
-
106
105
  private
107
106
 
108
107
  def build_validation_options(method, options = {})
@@ -13,7 +13,7 @@ module ClientSideValidations
13
13
  # We are not going to use super here, because we need
14
14
  # to inject the csv options in a data attribute in a clean way.
15
15
  # So we basically reimplement the whole form_for method
16
- raise ArgumentError, 'Missing block' unless block_given?
16
+ raise ArgumentError, 'Missing block' unless block
17
17
 
18
18
  html_options = options[:html] ||= {}
19
19
 
@@ -98,13 +98,16 @@ module ClientSideValidations
98
98
  def add_validator(validator_hash, validation_hash, name, attr)
99
99
  if validation_hash.key?(attr)
100
100
  validator_hash[name] = validation_hash[attr]
101
- elsif attr.to_s.ends_with?('_id')
102
- add_validator_with_association validator_hash, validation_hash, name, attr
101
+ elsif attr.to_s.end_with?('_id')
102
+ association_name = attr.to_s.gsub(/_id\Z/, '').to_sym
103
+ add_validator_with_association validator_hash, validation_hash, name, association_name
104
+ elsif attr.to_s.end_with?('_ids')
105
+ association_name = attr.to_s.gsub(/_ids\Z/, '').pluralize.to_sym
106
+ add_validator_with_association validator_hash, validation_hash, name, association_name
103
107
  end
104
108
  end
105
109
 
106
- def add_validator_with_association(validator_hash, validation_hash, name, attr)
107
- association_name = attr.to_s.gsub(/_id\Z/, '').to_sym
110
+ def add_validator_with_association(validator_hash, validation_hash, name, association_name)
108
111
  return unless validation_hash.key?(association_name)
109
112
 
110
113
  validator_hash[name] = validation_hash[association_name]
@@ -12,7 +12,7 @@ module ClientSideValidations
12
12
 
13
13
  url, model, scope = check_model(url, model, format, scope) if model
14
14
 
15
- if block_given?
15
+ if block
16
16
  form_tag_with_validators scope, model, options, url, &block
17
17
  else
18
18
  html_options = html_options_for_form_with(url, model, **options)
@@ -36,9 +36,11 @@ module ClientSideValidations
36
36
  module Validations
37
37
  include ClientSideValidations::ActiveModel::Conditionals
38
38
 
39
+ ATTRIBUTES_DENYLIST = [nil, :block].freeze
40
+
39
41
  def client_side_validation_hash(force = nil)
40
42
  _validators.inject({}) do |attr_hash, attr|
41
- next attr_hash if [nil, :block].include?(attr[0])
43
+ next attr_hash if ATTRIBUTES_DENYLIST.include?(attr[0])
42
44
 
43
45
  validator_hash = validator_hash_for(attr, force)
44
46
 
@@ -91,7 +93,7 @@ module ClientSideValidations
91
93
  end
92
94
 
93
95
  def will_save_change?(options)
94
- options.is_a?(Symbol) && (options.to_s.ends_with?('changed?') || options.to_s.starts_with?('will_save_change_to'))
96
+ options.is_a?(Symbol) && (options.to_s.end_with?('changed?') || options.to_s.start_with?('will_save_change_to'))
95
97
  end
96
98
 
97
99
  def check_conditionals(attr, validator, force)
@@ -28,9 +28,9 @@ module ClientSideValidations
28
28
  raise ArgumentError, 'Missing argument'
29
29
  end
30
30
  when String
31
- # rubocop:disable Security/Eval'
32
- l = eval("lambda { |value| #{conditional} }", binding, __FILE__, __LINE__)
33
- # rubocop:enable Security/Eval'
31
+ # rubocop:disable Security/Eval, Style/DocumentDynamicEvalDefinition
32
+ l = eval("->(value) { #{conditional} }", binding, __FILE__, __LINE__)
33
+ # rubocop:enable Security/Eval, Style/DocumentDynamicEvalDefinition
34
34
  instance_exec(nil, &l)
35
35
  when Symbol
36
36
  send conditional
@@ -7,6 +7,7 @@ module ClientSideValidations
7
7
 
8
8
  def self.included(base)
9
9
  @@option_map.merge!(base::CHECKS.keys.inject({}) { |acc, elem| acc.merge!(elem => elem) })
10
+ super
10
11
  end
11
12
 
12
13
  def client_side_hash(model, attribute, force = nil)
@@ -3,9 +3,7 @@
3
3
  module ClientSideValidations
4
4
  module Config
5
5
  class << self
6
- attr_accessor :disabled_validators
7
- attr_accessor :number_format_with_locale
8
- attr_accessor :root_path
6
+ attr_accessor :disabled_validators, :number_format_with_locale, :root_path
9
7
  end
10
8
 
11
9
  self.disabled_validators = []
@@ -4,7 +4,7 @@
4
4
 
5
5
  module ClientSideValidations
6
6
  module Files
7
- Initializer = File.expand_path(File.dirname(__FILE__) + '/../generators/templates/client_side_validations/initializer.rb')
8
- Javascript = File.expand_path(File.dirname(__FILE__) + '/../../vendor/assets/javascripts/rails.validations.js')
7
+ Initializer = File.expand_path('../generators/templates/client_side_validations/initializer.rb', __dir__)
8
+ Javascript = File.expand_path('../../vendor/assets/javascripts/rails.validations.js', __dir__)
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '16.2.0'
4
+ VERSION = '18.0.0'
5
5
  end
@@ -4,7 +4,7 @@ module ClientSideValidations
4
4
  module Generators
5
5
  class CopyAssetsGenerator < Rails::Generators::Base
6
6
  def copy_javascript_asset
7
- return unless self.class == CopyAssetsGenerator || !asset_pipeline_enabled?
7
+ return unless instance_of?(CopyAssetsGenerator) || copy_assets?
8
8
 
9
9
  assets.each do |asset|
10
10
  source_paths << asset[:path]
@@ -13,7 +13,7 @@ module ClientSideValidations
13
13
  end
14
14
 
15
15
  def self.asset_directory
16
- if asset_pipeline_enabled?
16
+ if sprockets?
17
17
  "app#{Rails.configuration.assets.prefix}/javascripts"
18
18
  else
19
19
  'public/javascripts'
@@ -28,9 +28,16 @@ module ClientSideValidations
28
28
  assets.map { |asset| asset[:file] }.join(', ')
29
29
  end
30
30
 
31
- def self.asset_pipeline_enabled?
32
- # Rails 4.1 doesn't provide :enabled in asset configuration, so we look for Sprockets
33
- defined?(Sprockets).present?
31
+ def self.copy_assets?
32
+ !sprockets? && !webpacker?
33
+ end
34
+
35
+ def self.sprockets?
36
+ defined?(Sprockets)
37
+ end
38
+
39
+ def self.webpacker?
40
+ defined?(Webpacker)
34
41
  end
35
42
 
36
43
  def self.installation_message
@@ -49,8 +56,8 @@ module ClientSideValidations
49
56
  CopyAssetsGenerator.assets
50
57
  end
51
58
 
52
- def asset_pipeline_enabled?
53
- self.class.asset_pipeline_enabled?
59
+ def copy_assets?
60
+ self.class.copy_assets?
54
61
  end
55
62
  end
56
63
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'generators/client_side_validations/copy_assets_generator'
3
+ require_relative 'copy_assets_generator'
4
4
 
5
5
  module ClientSideValidations
6
6
  module Generators
@@ -1,16 +1,18 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.3 (https://github.com/DavyJonesLocker/client_side_validations)
3
- * Copyright (c) 2020 Geremia Taglialatela, Brian Cardarella
2
+ * Client Side Validations JS - v0.1.5 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Copyright (c) 2021 Geremia Taglialatela, Brian Cardarella
4
4
  * Licensed under MIT (https://opensource.org/licenses/mit-license.php)
5
5
  */
6
6
 
7
7
  (function (global, factory) {
8
8
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) :
9
9
  typeof define === 'function' && define.amd ? define(['jquery'], factory) :
10
- (global = global || self, global.ClientSideValidations = factory(global.$));
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ClientSideValidations = factory(global.$));
11
11
  }(this, (function ($) { 'use strict';
12
12
 
13
- $ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var $__default = /*#__PURE__*/_interopDefaultLegacy($);
14
16
 
15
17
  function _typeof(obj) {
16
18
  "@babel/helpers - typeof";
@@ -78,25 +80,25 @@
78
80
  input: function input(form) {
79
81
  return {
80
82
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
81
- $(this).isValid(form.ClientSideValidations.settings.validators);
83
+ $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
82
84
  },
83
85
  'change.ClientSideValidations': function changeClientSideValidations() {
84
- $(this).data('changed', true);
86
+ $__default['default'](this).data('changed', true);
85
87
  },
86
88
  'element:validate:after.ClientSideValidations': function elementValidateAfterClientSideValidations(eventData) {
87
- ClientSideValidations.callbacks.element.after($(this), eventData);
89
+ ClientSideValidations.callbacks.element.after($__default['default'](this), eventData);
88
90
  },
89
91
  'element:validate:before.ClientSideValidations': function elementValidateBeforeClientSideValidations(eventData) {
90
- ClientSideValidations.callbacks.element.before($(this), eventData);
92
+ ClientSideValidations.callbacks.element.before($__default['default'](this), eventData);
91
93
  },
92
94
  'element:validate:fail.ClientSideValidations': function elementValidateFailClientSideValidations(eventData, message) {
93
- var $element = $(this);
95
+ var $element = $__default['default'](this);
94
96
  ClientSideValidations.callbacks.element.fail($element, message, function () {
95
97
  return form.ClientSideValidations.addError($element, message);
96
98
  }, eventData);
97
99
  },
98
100
  'element:validate:pass.ClientSideValidations': function elementValidatePassClientSideValidations(eventData) {
99
- var $element = $(this);
101
+ var $element = $__default['default'](this);
100
102
  ClientSideValidations.callbacks.element.pass($element, function () {
101
103
  return form.ClientSideValidations.removeError($element);
102
104
  }, eventData);
@@ -116,7 +118,7 @@
116
118
  },
117
119
  enablers: {
118
120
  form: function form(_form2) {
119
- var $form = $(_form2);
121
+ var $form = $__default['default'](_form2);
120
122
  _form2.ClientSideValidations = {
121
123
  settings: $form.data('clientSideValidations'),
122
124
  addError: function addError(element, message) {
@@ -138,23 +140,23 @@
138
140
  });
139
141
  },
140
142
  input: function input(_input) {
141
- var $input = $(_input);
143
+ var $input = $__default['default'](_input);
142
144
  var form = _input.form;
143
- var $form = $(form);
145
+ var $form = $__default['default'](form);
144
146
  var eventsToBind = ClientSideValidations.eventsToBind.input(form);
145
147
 
146
148
  for (var eventName in eventsToBind) {
147
149
  var eventFunction = eventsToBind[eventName];
148
150
  $input.filter(':not(:radio):not([id$=_confirmation])').each(function () {
149
- return $(this).attr('data-validate', true);
151
+ return $__default['default'](this).attr('data-validate', true);
150
152
  }).on(eventName, eventFunction);
151
153
  }
152
154
 
153
155
  $input.filter(':checkbox').on('change.ClientSideValidations', function () {
154
- $(this).isValid(form.ClientSideValidations.settings.validators);
156
+ $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
155
157
  });
156
158
  $input.filter('[id$=_confirmation]').each(function () {
157
- var $element = $(this);
159
+ var $element = $__default['default'](this);
158
160
  var $elementToConfirm = $form.find('#' + this.id.match(/(.+)_confirmation/)[1] + ':input');
159
161
 
160
162
  if ($elementToConfirm.length) {
@@ -162,7 +164,7 @@
162
164
 
163
165
  for (var _eventName in _eventsToBind) {
164
166
  var _eventFunction = _eventsToBind[_eventName];
165
- $('#' + $element.attr('id')).on(_eventName, _eventFunction);
167
+ $__default['default']('#' + $element.attr('id')).on(_eventName, _eventFunction);
166
168
  }
167
169
  }
168
170
  });
@@ -171,11 +173,11 @@
171
173
  formBuilders: {
172
174
  'ActionView::Helpers::FormBuilder': {
173
175
  add: function add(element, settings, message) {
174
- var form = $(element[0].form);
176
+ var form = $__default['default'](element[0].form);
175
177
 
176
178
  if (element.data('valid') !== false && form.find("label.message[for='" + element.attr('id') + "']")[0] == null) {
177
- var inputErrorField = $(settings.input_tag);
178
- var labelErrorField = $(settings.label_tag);
179
+ var inputErrorField = $__default['default'](settings.input_tag);
180
+ var labelErrorField = $__default['default'](settings.label_tag);
179
181
  var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
180
182
 
181
183
  if (element.attr('autofocus')) {
@@ -193,11 +195,12 @@
193
195
  form.find("label.message[for='" + element.attr('id') + "']").text(message);
194
196
  },
195
197
  remove: function remove(element, settings) {
196
- var form = $(element[0].form);
197
- var errorFieldClass = $(settings.input_tag).attr('class');
198
- var inputErrorField = element.closest('.' + errorFieldClass.replace(/ /g, '.'));
198
+ var form = $__default['default'](element[0].form);
199
+ var inputErrorFieldClass = $__default['default'](settings.input_tag).attr('class');
200
+ var inputErrorField = element.closest('.' + inputErrorFieldClass.replace(/ /g, '.'));
199
201
  var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
200
- var labelErrorField = label.closest('.' + errorFieldClass);
202
+ var labelErrorFieldClass = $__default['default'](settings.label_tag).attr('class');
203
+ var labelErrorField = label.closest('.' + labelErrorFieldClass.replace(/ /g, '.'));
201
204
 
202
205
  if (inputErrorField[0]) {
203
206
  inputErrorField.find('#' + element.attr('id')).detach();
@@ -210,8 +213,8 @@
210
213
  },
211
214
  patterns: {
212
215
  numericality: {
213
- "default": new RegExp('^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'),
214
- only_integer: new RegExp('^[+-]?\\d+$')
216
+ "default": /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
217
+ only_integer: /^[+-]?\d+$/
215
218
  }
216
219
  },
217
220
  selectors: {
@@ -221,13 +224,13 @@
221
224
  },
222
225
  validators: {
223
226
  all: function all() {
224
- return $.extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
227
+ return $__default['default'].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
225
228
  },
226
229
  local: {},
227
230
  remote: {}
228
231
  },
229
232
  disable: function disable(target) {
230
- var $target = $(target);
233
+ var $target = $__default['default'](target);
231
234
  $target.off('.ClientSideValidations');
232
235
 
233
236
  if ($target.is('form')) {
@@ -235,12 +238,12 @@
235
238
  } else {
236
239
  $target.removeData(['changed', 'valid']);
237
240
  $target.filter(':input').each(function () {
238
- $(this).removeAttr('data-validate');
241
+ $__default['default'](this).removeAttr('data-validate');
239
242
  });
240
243
  }
241
244
  },
242
245
  reset: function reset(form) {
243
- var $form = $(form);
246
+ var $form = $__default['default'](form);
244
247
  ClientSideValidations.disable(form);
245
248
 
246
249
  for (var key in form.ClientSideValidations.settings.validators) {
@@ -252,12 +255,12 @@
252
255
  start: function start() {
253
256
  if (window.Turbolinks != null && window.Turbolinks.supported) {
254
257
  var initializeOnEvent = window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
255
- $(document).on(initializeOnEvent, function () {
256
- return $(ClientSideValidations.selectors.forms).validate();
258
+ $__default['default'](document).on(initializeOnEvent, function () {
259
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
257
260
  });
258
261
  } else {
259
- $(function () {
260
- return $(ClientSideValidations.selectors.forms).validate();
262
+ $__default['default'](function () {
263
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
261
264
  });
262
265
  }
263
266
  }
@@ -374,7 +377,7 @@
374
377
 
375
378
  if (validationElement.length === 1) {
376
379
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
377
- var otherFormattedValue = $.trim(validationElement.val()).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
380
+ var otherFormattedValue = $__default['default'].trim(validationElement.val()).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
378
381
 
379
382
  if (!isNaN(parseFloat(otherFormattedValue))) {
380
383
  return otherFormattedValue;
@@ -425,9 +428,9 @@
425
428
  return;
426
429
  }
427
430
 
428
- var $form = $(element[0].form);
431
+ var $form = $__default['default'](element[0].form);
429
432
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
430
- var formattedValue = $.trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
433
+ var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
431
434
  return runValidations(formattedValue, $form, options);
432
435
  };
433
436
 
@@ -501,7 +504,7 @@
501
504
 
502
505
  var confirmationLocalValidator = function confirmationLocalValidator(element, options) {
503
506
  var value = element.val();
504
- var confirmationValue = $('#' + element.attr('id') + '_confirmation').val();
507
+ var confirmationValue = $__default['default']('#' + element.attr('id') + '_confirmation').val();
505
508
 
506
509
  if (!options.case_sensitive) {
507
510
  value = value.toLowerCase();
@@ -520,12 +523,12 @@
520
523
  }
521
524
 
522
525
  if (otherValue === value) {
523
- $(currentElement).data('notLocallyUnique', true);
526
+ $__default['default'](currentElement).data('notLocallyUnique', true);
524
527
  return false;
525
528
  }
526
529
 
527
- if ($(currentElement).data('notLocallyUnique')) {
528
- $(currentElement).removeData('notLocallyUnique').data('changed', true);
530
+ if ($__default['default'](currentElement).data('notLocallyUnique')) {
531
+ $__default['default'](currentElement).removeData('notLocallyUnique').data('changed', true);
529
532
  }
530
533
 
531
534
  return true;
@@ -543,7 +546,7 @@
543
546
  var value = element.val();
544
547
  var valid = true;
545
548
  form.find(':input[name^="' + matches[1] + '"][name$="' + matches[2] + '"]').not(element).each(function () {
546
- var otherValue = $(this).val();
549
+ var otherValue = $__default['default'](this).val();
547
550
 
548
551
  if (!isLocallyUnique(this, value, otherValue, options.case_sensitive)) {
549
552
  valid = false;
@@ -568,12 +571,12 @@
568
571
  uniqueness: uniquenessLocalValidator
569
572
  };
570
573
 
571
- $.fn.disableClientSideValidations = function () {
574
+ $__default['default'].fn.disableClientSideValidations = function () {
572
575
  ClientSideValidations.disable(this);
573
576
  return this;
574
577
  };
575
578
 
576
- $.fn.enableClientSideValidations = function () {
579
+ $__default['default'].fn.enableClientSideValidations = function () {
577
580
  var _this = this;
578
581
 
579
582
  var selectors = {
@@ -581,7 +584,7 @@
581
584
  inputs: 'input'
582
585
  };
583
586
 
584
- var _loop = function _loop() {
587
+ var _loop = function _loop(selector) {
585
588
  var enablers = selectors[selector];
586
589
 
587
590
  _this.filter(ClientSideValidations.selectors[selector]).each(function () {
@@ -590,28 +593,28 @@
590
593
  };
591
594
 
592
595
  for (var selector in selectors) {
593
- _loop();
596
+ _loop(selector);
594
597
  }
595
598
 
596
599
  return this;
597
600
  };
598
601
 
599
- $.fn.resetClientSideValidations = function () {
602
+ $__default['default'].fn.resetClientSideValidations = function () {
600
603
  this.filter(ClientSideValidations.selectors.forms).each(function () {
601
604
  return ClientSideValidations.reset(this);
602
605
  });
603
606
  return this;
604
607
  };
605
608
 
606
- $.fn.validate = function () {
609
+ $__default['default'].fn.validate = function () {
607
610
  this.filter(ClientSideValidations.selectors.forms).each(function () {
608
- return $(this).enableClientSideValidations();
611
+ return $__default['default'](this).enableClientSideValidations();
609
612
  });
610
613
  return this;
611
614
  };
612
615
 
613
- $.fn.isValid = function (validators) {
614
- var obj = $(this[0]);
616
+ $__default['default'].fn.isValid = function (validators) {
617
+ var obj = $__default['default'](this[0]);
615
618
 
616
619
  if (obj.is('form')) {
617
620
  return validateForm(obj, validators);
@@ -653,7 +656,7 @@
653
656
  var valid = true;
654
657
  form.trigger('form:validate:before.ClientSideValidations');
655
658
  form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
656
- if (!$(this).isValid(validators)) {
659
+ if (!$__default['default'](this).isValid(validators)) {
657
660
  valid = false;
658
661
  }
659
662
 
@@ -717,7 +720,7 @@
717
720
  if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
718
721
  var destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
719
722
 
720
- if ($("input[name='" + destroyInputName + "']").val() === '1') {
723
+ if ($__default['default']("input[name='" + destroyInputName + "']").val() === '1') {
721
724
  return true;
722
725
  }
723
726
  }
@@ -726,7 +729,7 @@
726
729
  };
727
730
 
728
731
  var executeAllValidators = function executeAllValidators(element, validators) {
729
- if (element.data('changed') === false) {
732
+ if (element.data('changed') === false || element.prop('disabled')) {
730
733
  return;
731
734
  }
732
735
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.2.0
4
+ version: 18.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
8
8
  - Brian Cardarella
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-11 00:00:00.000000000 Z
12
+ date: 2021-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -20,7 +20,7 @@ dependencies:
20
20
  version: 5.0.0.1
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '6.1'
23
+ version: '7.0'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -30,21 +30,7 @@ dependencies:
30
30
  version: 5.0.0.1
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
34
- - !ruby/object:Gem::Dependency
35
- name: jquery-rails
36
- requirement: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '4.3'
41
- type: :runtime
42
- prerelease: false
43
- version_requirements: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '4.3'
33
+ version: '7.0'
48
34
  - !ruby/object:Gem::Dependency
49
35
  name: js_regex
50
36
  requirement: !ruby/object:Gem::Requirement
@@ -65,54 +51,42 @@ dependencies:
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '2.2'
54
+ version: '2.3'
69
55
  type: :development
70
56
  prerelease: false
71
57
  version_requirements: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - "~>"
74
60
  - !ruby/object:Gem::Version
75
- version: '2.2'
61
+ version: '2.3'
76
62
  - !ruby/object:Gem::Dependency
77
63
  name: byebug
78
64
  requirement: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '10.0'
83
- - - "<"
66
+ - - "~>"
84
67
  - !ruby/object:Gem::Version
85
- version: '12'
68
+ version: '11.1'
86
69
  type: :development
87
70
  prerelease: false
88
71
  version_requirements: !ruby/object:Gem::Requirement
89
72
  requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '10.0'
93
- - - "<"
73
+ - - "~>"
94
74
  - !ruby/object:Gem::Version
95
- version: '12'
75
+ version: '11.1'
96
76
  - !ruby/object:Gem::Dependency
97
77
  name: coveralls_reborn
98
78
  requirement: !ruby/object:Gem::Requirement
99
79
  requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- version: 0.14.0
103
- - - "<"
80
+ - - "~>"
104
81
  - !ruby/object:Gem::Version
105
- version: '0.16'
82
+ version: 0.20.0
106
83
  type: :development
107
84
  prerelease: false
108
85
  version_requirements: !ruby/object:Gem::Requirement
109
86
  requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
112
- version: 0.14.0
113
- - - "<"
87
+ - - "~>"
114
88
  - !ruby/object:Gem::Version
115
- version: '0.16'
89
+ version: 0.20.0
116
90
  - !ruby/object:Gem::Dependency
117
91
  name: m
118
92
  requirement: !ruby/object:Gem::Requirement
@@ -147,14 +121,14 @@ dependencies:
147
121
  requirements:
148
122
  - - "~>"
149
123
  - !ruby/object:Gem::Version
150
- version: '1.11'
124
+ version: '1.12'
151
125
  type: :development
152
126
  prerelease: false
153
127
  version_requirements: !ruby/object:Gem::Requirement
154
128
  requirements:
155
129
  - - "~>"
156
130
  - !ruby/object:Gem::Version
157
- version: '1.11'
131
+ version: '1.12'
158
132
  - !ruby/object:Gem::Dependency
159
133
  name: rake
160
134
  requirement: !ruby/object:Gem::Requirement
@@ -175,62 +149,90 @@ dependencies:
175
149
  requirements:
176
150
  - - "~>"
177
151
  - !ruby/object:Gem::Version
178
- version: 0.81.0
152
+ version: '1.9'
179
153
  type: :development
180
154
  prerelease: false
181
155
  version_requirements: !ruby/object:Gem::Requirement
182
156
  requirements:
183
157
  - - "~>"
184
158
  - !ruby/object:Gem::Version
185
- version: 0.81.0
159
+ version: '1.9'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rubocop-minitest
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.10.3
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.10.3
186
174
  - !ruby/object:Gem::Dependency
187
175
  name: rubocop-performance
188
176
  requirement: !ruby/object:Gem::Requirement
189
177
  requirements:
190
178
  - - "~>"
191
179
  - !ruby/object:Gem::Version
192
- version: '1.5'
180
+ version: '1.9'
193
181
  type: :development
194
182
  prerelease: false
195
183
  version_requirements: !ruby/object:Gem::Requirement
196
184
  requirements:
197
185
  - - "~>"
198
186
  - !ruby/object:Gem::Version
199
- version: '1.5'
187
+ version: '1.9'
200
188
  - !ruby/object:Gem::Dependency
201
189
  name: rubocop-rails
202
190
  requirement: !ruby/object:Gem::Requirement
203
191
  requirements:
204
192
  - - "~>"
205
193
  - !ruby/object:Gem::Version
206
- version: '2.5'
194
+ version: '2.9'
207
195
  type: :development
208
196
  prerelease: false
209
197
  version_requirements: !ruby/object:Gem::Requirement
210
198
  requirements:
211
199
  - - "~>"
212
200
  - !ruby/object:Gem::Version
213
- version: '2.5'
201
+ version: '2.9'
202
+ - !ruby/object:Gem::Dependency
203
+ name: rubocop-rake
204
+ requirement: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.5.1
209
+ type: :development
210
+ prerelease: false
211
+ version_requirements: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 0.5.1
214
216
  - !ruby/object:Gem::Dependency
215
217
  name: simplecov
216
218
  requirement: !ruby/object:Gem::Requirement
217
219
  requirements:
218
220
  - - ">="
219
221
  - !ruby/object:Gem::Version
220
- version: 0.17.1
222
+ version: 0.18.5
221
223
  - - "<"
222
224
  - !ruby/object:Gem::Version
223
- version: '0.19'
225
+ version: '0.22'
224
226
  type: :development
225
227
  prerelease: false
226
228
  version_requirements: !ruby/object:Gem::Requirement
227
229
  requirements:
228
230
  - - ">="
229
231
  - !ruby/object:Gem::Version
230
- version: 0.17.1
232
+ version: 0.18.5
231
233
  - - "<"
232
234
  - !ruby/object:Gem::Version
233
- version: '0.19'
235
+ version: '0.22'
234
236
  - !ruby/object:Gem::Dependency
235
237
  name: sqlite3
236
238
  requirement: !ruby/object:Gem::Requirement
@@ -265,16 +267,16 @@ dependencies:
265
267
  requirements:
266
268
  - - "~>"
267
269
  - !ruby/object:Gem::Version
268
- version: '2.0'
270
+ version: '2.1'
269
271
  type: :development
270
272
  prerelease: false
271
273
  version_requirements: !ruby/object:Gem::Requirement
272
274
  requirements:
273
275
  - - "~>"
274
276
  - !ruby/object:Gem::Version
275
- version: '2.0'
277
+ version: '2.1'
276
278
  - !ruby/object:Gem::Dependency
277
- name: thin
279
+ name: webrick
278
280
  requirement: !ruby/object:Gem::Requirement
279
281
  requirements:
280
282
  - - "~>"
@@ -334,25 +336,25 @@ licenses:
334
336
  - MIT
335
337
  metadata:
336
338
  bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
337
- changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/master/CHANGELOG.md
339
+ changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/main/CHANGELOG.md
338
340
  source_code_uri: https://github.com/DavyJonesLocker/client_side_validations
339
- post_install_message:
341
+ post_install_message:
340
342
  rdoc_options: []
341
343
  require_paths:
342
344
  - lib
343
345
  required_ruby_version: !ruby/object:Gem::Requirement
344
346
  requirements:
345
- - - "~>"
347
+ - - ">="
346
348
  - !ruby/object:Gem::Version
347
- version: '2.3'
349
+ version: '2.4'
348
350
  required_rubygems_version: !ruby/object:Gem::Requirement
349
351
  requirements:
350
352
  - - ">="
351
353
  - !ruby/object:Gem::Version
352
354
  version: '0'
353
355
  requirements: []
354
- rubygems_version: 3.1.2
355
- signing_key:
356
+ rubygems_version: 3.1.4
357
+ signing_key:
356
358
  specification_version: 4
357
359
  summary: Client Side Validations
358
360
  test_files: []