client_side_validations 16.1.0 → 17.1.1

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: 2272b945883cfdb72fbf231429196584c4075834e113770af87bba25bbf41995
4
- data.tar.gz: c5587482714b6a896b4539ed5520a97293c18837ba12062133f385ee117faf2b
3
+ metadata.gz: 0ed3f9c3cf23a21d2e70435fd69b7cff1bbd01b6f988eed6320d465bbd2969bd
4
+ data.tar.gz: 2ff0d23eb4b2da3777e3e4dd1b36d3457daa6755cf2769b02ddcda7c092afb17
5
5
  SHA512:
6
- metadata.gz: 69b603f083c013f0f2bd167aa55c8da3718ac81809a771206eff70de8c336cc83919e32af0181ac9e2eb7012b37c4ca726c9ae16f97e400e82886009f1f39f0a
7
- data.tar.gz: ab6de699af7702b0ccf173395cceb395a359fb7723a595f75d406e72565dae6c255977c8317ef7f08cc699cae2694d001f1c3fccdd3b70043861f57e2be50e9e
6
+ metadata.gz: 35998c36fc8089a8324b4cc5f220ad16dc591ffa0420f87827ae416cc4421c7579c291398c214d0a2ed53cdb7662b4b3d49be3077328bf0f09da842fc2c3d2c2
7
+ data.tar.gz: d2da4f06025ea743078a19d77b42f4d68e6c6ea33e4cd24ff3ff5a8c18fa05e81c247ffaeadd0379b835f74d1937766017438e370a060b4eb4203c3519c1141c
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 17.1.1 / 2020-10-31
4
+
5
+ * [ENHANCEMENT] Minor code cleanup
6
+ * [ENHANCEMENT] Update development dependencies
7
+
8
+ ## 17.1.0 / 2020-10-10
9
+
10
+ * [FEATURE] Allow Ruby 3.0.0
11
+ * [ENHANCEMENT] Test against latest Ruby 2.7.2
12
+ * [ENHANCEMENT] Update QUnit to 2.11.3
13
+ * [ENHANCEMENT] Update development dependencies
14
+
15
+ ## 17.0.0 / 2020-05-16
16
+
17
+ * [FEATURE] Drop Ruby 2.3 support
18
+ * [FEATURE] Do not require `jquery-rails` gem ([#785](https://github.com/DavyJonesLocker/client_side_validations/pull/785))
19
+ * [FEATURE] Add support for many association validations ([#783](https://github.com/DavyJonesLocker/client_side_validations/pull/783))
20
+ * [BUGFIX] Fix Rails generators ([#786](https://github.com/DavyJonesLocker/client_side_validations/pull/786))
21
+ * [BUGFIX] Do not validate dynamically disabled inputs ([#789](https://github.com/DavyJonesLocker/client_side_validations/pull/789))
22
+ * [BUGFIX] Fix removal of error messages ([#790](https://github.com/DavyJonesLocker/client_side_validations/pull/790))
23
+ * [ENHANCEMENT] Test against jQuery 3.5.1
24
+
25
+ ## 16.2.0 / 2020-04-10
26
+
27
+ * [FEATURE] Add jQuery 3.5.0 compatibility ([#779](https://github.com/DavyJonesLocker/client_side_validations/pull/779))
28
+ * [ENHANCEMENT] Test against latest Ruby versions
29
+ * [ENHANCEMENT] Update development dependencies
30
+
31
+ ## 16.1.1 / 2020-03-20
32
+
33
+ * [BUGFIX] Fix custom validators for nested attributes ([#778](https://github.com/DavyJonesLocker/client_side_validations/pull/778))
34
+ * [ENHANCEMENT] Update development dependencies
35
+
3
36
  ## 16.1.0 / 2019-12-25
4
37
 
5
38
  * [FEATURE] Ruby 2.7 support
data/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Geremia Taglialatela, Brian Cardarella
3
+ Copyright (c) 2020 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,10 +2,12 @@
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
+ [![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)
5
6
  [![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations.svg?branch=master)](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
8
  [![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
9
 
10
+
9
11
  `ClientSideValidations` made easy for your Rails 5.x / Rails 6.0 applications!
10
12
 
11
13
  ## Project Goals ##
@@ -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 ##
@@ -525,7 +543,7 @@ 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-2020
529
547
 
530
548
  [@dockyard](https://twitter.com/dockyard)
531
549
 
@@ -7,26 +7,30 @@ 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,
28
- input_tag: form_helper.class.field_error_proc.call(%(<span id="input_tag" />), Struct.new(:error_message, :tag_id).new([], '')),
29
- label_tag: form_helper.class.field_error_proc.call(%(<label id="label_tag" />), Struct.new(:error_message, :tag_id).new([], ''))
32
+ input_tag: form_helper.class.field_error_proc.call(%(<span id="input_tag"></span>), Struct.new(:error_message, :tag_id).new([], '')),
33
+ label_tag: form_helper.class.field_error_proc.call(%(<label id="label_tag"></label>), Struct.new(:error_message, :tag_id).new([], ''))
30
34
  }
31
35
  end
32
36
 
@@ -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 = {})
@@ -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]
@@ -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.1.0'
4
+ VERSION = '17.1.1'
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,18 +1,22 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.1 (https://github.com/DavyJonesLocker/client_side_validations)
3
- * Copyright (c) 2019 Geremia Taglialatela, Brian Cardarella
2
+ * Client Side Validations JS - v0.1.5 (https://github.com/DavyJonesLocker/client_side_validations)
3
+ * Copyright (c) 2020 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
- $ = $ && $.hasOwnProperty('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) {
18
+ "@babel/helpers - typeof";
19
+
16
20
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
17
21
  _typeof = function (obj) {
18
22
  return typeof obj;
@@ -76,25 +80,25 @@
76
80
  input: function input(form) {
77
81
  return {
78
82
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
79
- $(this).isValid(form.ClientSideValidations.settings.validators);
83
+ $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
80
84
  },
81
85
  'change.ClientSideValidations': function changeClientSideValidations() {
82
- $(this).data('changed', true);
86
+ $__default['default'](this).data('changed', true);
83
87
  },
84
88
  'element:validate:after.ClientSideValidations': function elementValidateAfterClientSideValidations(eventData) {
85
- ClientSideValidations.callbacks.element.after($(this), eventData);
89
+ ClientSideValidations.callbacks.element.after($__default['default'](this), eventData);
86
90
  },
87
91
  'element:validate:before.ClientSideValidations': function elementValidateBeforeClientSideValidations(eventData) {
88
- ClientSideValidations.callbacks.element.before($(this), eventData);
92
+ ClientSideValidations.callbacks.element.before($__default['default'](this), eventData);
89
93
  },
90
94
  'element:validate:fail.ClientSideValidations': function elementValidateFailClientSideValidations(eventData, message) {
91
- var $element = $(this);
95
+ var $element = $__default['default'](this);
92
96
  ClientSideValidations.callbacks.element.fail($element, message, function () {
93
97
  return form.ClientSideValidations.addError($element, message);
94
98
  }, eventData);
95
99
  },
96
100
  'element:validate:pass.ClientSideValidations': function elementValidatePassClientSideValidations(eventData) {
97
- var $element = $(this);
101
+ var $element = $__default['default'](this);
98
102
  ClientSideValidations.callbacks.element.pass($element, function () {
99
103
  return form.ClientSideValidations.removeError($element);
100
104
  }, eventData);
@@ -114,7 +118,7 @@
114
118
  },
115
119
  enablers: {
116
120
  form: function form(_form2) {
117
- var $form = $(_form2);
121
+ var $form = $__default['default'](_form2);
118
122
  _form2.ClientSideValidations = {
119
123
  settings: $form.data('clientSideValidations'),
120
124
  addError: function addError(element, message) {
@@ -136,23 +140,23 @@
136
140
  });
137
141
  },
138
142
  input: function input(_input) {
139
- var $input = $(_input);
143
+ var $input = $__default['default'](_input);
140
144
  var form = _input.form;
141
- var $form = $(form);
145
+ var $form = $__default['default'](form);
142
146
  var eventsToBind = ClientSideValidations.eventsToBind.input(form);
143
147
 
144
148
  for (var eventName in eventsToBind) {
145
149
  var eventFunction = eventsToBind[eventName];
146
150
  $input.filter(':not(:radio):not([id$=_confirmation])').each(function () {
147
- return $(this).attr('data-validate', true);
151
+ return $__default['default'](this).attr('data-validate', true);
148
152
  }).on(eventName, eventFunction);
149
153
  }
150
154
 
151
155
  $input.filter(':checkbox').on('change.ClientSideValidations', function () {
152
- $(this).isValid(form.ClientSideValidations.settings.validators);
156
+ $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
153
157
  });
154
158
  $input.filter('[id$=_confirmation]').each(function () {
155
- var $element = $(this);
159
+ var $element = $__default['default'](this);
156
160
  var $elementToConfirm = $form.find('#' + this.id.match(/(.+)_confirmation/)[1] + ':input');
157
161
 
158
162
  if ($elementToConfirm.length) {
@@ -160,7 +164,7 @@
160
164
 
161
165
  for (var _eventName in _eventsToBind) {
162
166
  var _eventFunction = _eventsToBind[_eventName];
163
- $('#' + $element.attr('id')).on(_eventName, _eventFunction);
167
+ $__default['default']('#' + $element.attr('id')).on(_eventName, _eventFunction);
164
168
  }
165
169
  }
166
170
  });
@@ -169,11 +173,11 @@
169
173
  formBuilders: {
170
174
  'ActionView::Helpers::FormBuilder': {
171
175
  add: function add(element, settings, message) {
172
- var form = $(element[0].form);
176
+ var form = $__default['default'](element[0].form);
173
177
 
174
178
  if (element.data('valid') !== false && form.find("label.message[for='" + element.attr('id') + "']")[0] == null) {
175
- var inputErrorField = $(settings.input_tag);
176
- var labelErrorField = $(settings.label_tag);
179
+ var inputErrorField = $__default['default'](settings.input_tag);
180
+ var labelErrorField = $__default['default'](settings.label_tag);
177
181
  var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
178
182
 
179
183
  if (element.attr('autofocus')) {
@@ -191,11 +195,12 @@
191
195
  form.find("label.message[for='" + element.attr('id') + "']").text(message);
192
196
  },
193
197
  remove: function remove(element, settings) {
194
- var form = $(element[0].form);
195
- var errorFieldClass = $(settings.input_tag).attr('class');
196
- 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, '.'));
197
201
  var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
198
- var labelErrorField = label.closest('.' + errorFieldClass);
202
+ var labelErrorFieldClass = $__default['default'](settings.label_tag).attr('class');
203
+ var labelErrorField = label.closest('.' + labelErrorFieldClass.replace(/ /g, '.'));
199
204
 
200
205
  if (inputErrorField[0]) {
201
206
  inputErrorField.find('#' + element.attr('id')).detach();
@@ -208,8 +213,8 @@
208
213
  },
209
214
  patterns: {
210
215
  numericality: {
211
- "default": new RegExp('^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'),
212
- only_integer: new RegExp('^[+-]?\\d+$')
216
+ "default": /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
217
+ only_integer: /^[+-]?\d+$/
213
218
  }
214
219
  },
215
220
  selectors: {
@@ -219,13 +224,13 @@
219
224
  },
220
225
  validators: {
221
226
  all: function all() {
222
- return $.extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
227
+ return $__default['default'].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
223
228
  },
224
229
  local: {},
225
230
  remote: {}
226
231
  },
227
232
  disable: function disable(target) {
228
- var $target = $(target);
233
+ var $target = $__default['default'](target);
229
234
  $target.off('.ClientSideValidations');
230
235
 
231
236
  if ($target.is('form')) {
@@ -233,12 +238,12 @@
233
238
  } else {
234
239
  $target.removeData(['changed', 'valid']);
235
240
  $target.filter(':input').each(function () {
236
- $(this).removeAttr('data-validate');
241
+ $__default['default'](this).removeAttr('data-validate');
237
242
  });
238
243
  }
239
244
  },
240
245
  reset: function reset(form) {
241
- var $form = $(form);
246
+ var $form = $__default['default'](form);
242
247
  ClientSideValidations.disable(form);
243
248
 
244
249
  for (var key in form.ClientSideValidations.settings.validators) {
@@ -250,12 +255,12 @@
250
255
  start: function start() {
251
256
  if (window.Turbolinks != null && window.Turbolinks.supported) {
252
257
  var initializeOnEvent = window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
253
- $(document).on(initializeOnEvent, function () {
254
- return $(ClientSideValidations.selectors.forms).validate();
258
+ $__default['default'](document).on(initializeOnEvent, function () {
259
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
255
260
  });
256
261
  } else {
257
- $(function () {
258
- return $(ClientSideValidations.selectors.forms).validate();
262
+ $__default['default'](function () {
263
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
259
264
  });
260
265
  }
261
266
  }
@@ -372,7 +377,7 @@
372
377
 
373
378
  if (validationElement.length === 1) {
374
379
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
375
- 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'), '.');
376
381
 
377
382
  if (!isNaN(parseFloat(otherFormattedValue))) {
378
383
  return otherFormattedValue;
@@ -423,9 +428,9 @@
423
428
  return;
424
429
  }
425
430
 
426
- var $form = $(element[0].form);
431
+ var $form = $__default['default'](element[0].form);
427
432
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
428
- var formattedValue = $.trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
433
+ var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
429
434
  return runValidations(formattedValue, $form, options);
430
435
  };
431
436
 
@@ -499,7 +504,7 @@
499
504
 
500
505
  var confirmationLocalValidator = function confirmationLocalValidator(element, options) {
501
506
  var value = element.val();
502
- var confirmationValue = $('#' + element.attr('id') + '_confirmation').val();
507
+ var confirmationValue = $__default['default']('#' + element.attr('id') + '_confirmation').val();
503
508
 
504
509
  if (!options.case_sensitive) {
505
510
  value = value.toLowerCase();
@@ -518,12 +523,12 @@
518
523
  }
519
524
 
520
525
  if (otherValue === value) {
521
- $(currentElement).data('notLocallyUnique', true);
526
+ $__default['default'](currentElement).data('notLocallyUnique', true);
522
527
  return false;
523
528
  }
524
529
 
525
- if ($(currentElement).data('notLocallyUnique')) {
526
- $(currentElement).removeData('notLocallyUnique').data('changed', true);
530
+ if ($__default['default'](currentElement).data('notLocallyUnique')) {
531
+ $__default['default'](currentElement).removeData('notLocallyUnique').data('changed', true);
527
532
  }
528
533
 
529
534
  return true;
@@ -541,7 +546,7 @@
541
546
  var value = element.val();
542
547
  var valid = true;
543
548
  form.find(':input[name^="' + matches[1] + '"][name$="' + matches[2] + '"]').not(element).each(function () {
544
- var otherValue = $(this).val();
549
+ var otherValue = $__default['default'](this).val();
545
550
 
546
551
  if (!isLocallyUnique(this, value, otherValue, options.case_sensitive)) {
547
552
  valid = false;
@@ -566,12 +571,12 @@
566
571
  uniqueness: uniquenessLocalValidator
567
572
  };
568
573
 
569
- $.fn.disableClientSideValidations = function () {
574
+ $__default['default'].fn.disableClientSideValidations = function () {
570
575
  ClientSideValidations.disable(this);
571
576
  return this;
572
577
  };
573
578
 
574
- $.fn.enableClientSideValidations = function () {
579
+ $__default['default'].fn.enableClientSideValidations = function () {
575
580
  var _this = this;
576
581
 
577
582
  var selectors = {
@@ -579,7 +584,7 @@
579
584
  inputs: 'input'
580
585
  };
581
586
 
582
- var _loop = function _loop() {
587
+ var _loop = function _loop(selector) {
583
588
  var enablers = selectors[selector];
584
589
 
585
590
  _this.filter(ClientSideValidations.selectors[selector]).each(function () {
@@ -588,28 +593,28 @@
588
593
  };
589
594
 
590
595
  for (var selector in selectors) {
591
- _loop();
596
+ _loop(selector);
592
597
  }
593
598
 
594
599
  return this;
595
600
  };
596
601
 
597
- $.fn.resetClientSideValidations = function () {
602
+ $__default['default'].fn.resetClientSideValidations = function () {
598
603
  this.filter(ClientSideValidations.selectors.forms).each(function () {
599
604
  return ClientSideValidations.reset(this);
600
605
  });
601
606
  return this;
602
607
  };
603
608
 
604
- $.fn.validate = function () {
609
+ $__default['default'].fn.validate = function () {
605
610
  this.filter(ClientSideValidations.selectors.forms).each(function () {
606
- return $(this).enableClientSideValidations();
611
+ return $__default['default'](this).enableClientSideValidations();
607
612
  });
608
613
  return this;
609
614
  };
610
615
 
611
- $.fn.isValid = function (validators) {
612
- var obj = $(this[0]);
616
+ $__default['default'].fn.isValid = function (validators) {
617
+ var obj = $__default['default'](this[0]);
613
618
 
614
619
  if (obj.is('form')) {
615
620
  return validateForm(obj, validators);
@@ -640,7 +645,7 @@
640
645
  };
641
646
 
642
647
  var validatorsFor = function validatorsFor(elementName, validators) {
643
- if (Object.prototype.isPrototypeOf.call(validators, elementName)) {
648
+ if (Object.prototype.hasOwnProperty.call(validators, elementName)) {
644
649
  return validators[elementName];
645
650
  }
646
651
 
@@ -651,7 +656,7 @@
651
656
  var valid = true;
652
657
  form.trigger('form:validate:before.ClientSideValidations');
653
658
  form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
654
- if (!$(this).isValid(validators)) {
659
+ if (!$__default['default'](this).isValid(validators)) {
655
660
  valid = false;
656
661
  }
657
662
 
@@ -715,7 +720,7 @@
715
720
  if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
716
721
  var destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
717
722
 
718
- if ($("input[name='" + destroyInputName + "']").val() === '1') {
723
+ if ($__default['default']("input[name='" + destroyInputName + "']").val() === '1') {
719
724
  return true;
720
725
  }
721
726
  }
@@ -724,7 +729,7 @@
724
729
  };
725
730
 
726
731
  var executeAllValidators = function executeAllValidators(element, validators) {
727
- if (element.data('changed') === false) {
732
+ if (element.data('changed') === false || element.prop('disabled')) {
728
733
  return;
729
734
  }
730
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.1.0
4
+ version: 17.1.1
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: 2019-12-25 00:00:00.000000000 Z
12
+ date: 2020-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,20 +31,6 @@ dependencies:
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
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'
48
34
  - !ruby/object:Gem::Dependency
49
35
  name: js_regex
50
36
  requirement: !ruby/object:Gem::Requirement
@@ -65,48 +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
80
  - - "~>"
101
81
  - !ruby/object:Gem::Version
102
- version: 0.14.0
82
+ version: 0.18.0
103
83
  type: :development
104
84
  prerelease: false
105
85
  version_requirements: !ruby/object:Gem::Requirement
106
86
  requirements:
107
87
  - - "~>"
108
88
  - !ruby/object:Gem::Version
109
- version: 0.14.0
89
+ version: 0.18.0
110
90
  - !ruby/object:Gem::Dependency
111
91
  name: m
112
92
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +107,14 @@ dependencies:
127
107
  requirements:
128
108
  - - "~>"
129
109
  - !ruby/object:Gem::Version
130
- version: '5.13'
110
+ version: '5.14'
131
111
  type: :development
132
112
  prerelease: false
133
113
  version_requirements: !ruby/object:Gem::Requirement
134
114
  requirements:
135
115
  - - "~>"
136
116
  - !ruby/object:Gem::Version
137
- version: '5.13'
117
+ version: '5.14'
138
118
  - !ruby/object:Gem::Dependency
139
119
  name: mocha
140
120
  requirement: !ruby/object:Gem::Requirement
@@ -169,56 +149,62 @@ dependencies:
169
149
  requirements:
170
150
  - - "~>"
171
151
  - !ruby/object:Gem::Version
172
- version: 0.78.0
152
+ version: 1.1.0
173
153
  type: :development
174
154
  prerelease: false
175
155
  version_requirements: !ruby/object:Gem::Requirement
176
156
  requirements:
177
157
  - - "~>"
178
158
  - !ruby/object:Gem::Version
179
- version: 0.78.0
159
+ version: 1.1.0
180
160
  - !ruby/object:Gem::Dependency
181
161
  name: rubocop-performance
182
162
  requirement: !ruby/object:Gem::Requirement
183
163
  requirements:
184
164
  - - "~>"
185
165
  - !ruby/object:Gem::Version
186
- version: '1.5'
166
+ version: '1.8'
187
167
  type: :development
188
168
  prerelease: false
189
169
  version_requirements: !ruby/object:Gem::Requirement
190
170
  requirements:
191
171
  - - "~>"
192
172
  - !ruby/object:Gem::Version
193
- version: '1.5'
173
+ version: '1.8'
194
174
  - !ruby/object:Gem::Dependency
195
175
  name: rubocop-rails
196
176
  requirement: !ruby/object:Gem::Requirement
197
177
  requirements:
198
178
  - - "~>"
199
179
  - !ruby/object:Gem::Version
200
- version: '2.4'
180
+ version: '2.8'
201
181
  type: :development
202
182
  prerelease: false
203
183
  version_requirements: !ruby/object:Gem::Requirement
204
184
  requirements:
205
185
  - - "~>"
206
186
  - !ruby/object:Gem::Version
207
- version: '2.4'
187
+ version: '2.8'
208
188
  - !ruby/object:Gem::Dependency
209
189
  name: simplecov
210
190
  requirement: !ruby/object:Gem::Requirement
211
191
  requirements:
212
- - - "~>"
192
+ - - ">="
213
193
  - !ruby/object:Gem::Version
214
- version: 0.17.1
194
+ version: 0.18.5
195
+ - - "<"
196
+ - !ruby/object:Gem::Version
197
+ version: '0.20'
215
198
  type: :development
216
199
  prerelease: false
217
200
  version_requirements: !ruby/object:Gem::Requirement
218
201
  requirements:
219
- - - "~>"
202
+ - - ">="
220
203
  - !ruby/object:Gem::Version
221
- version: 0.17.1
204
+ version: 0.18.5
205
+ - - "<"
206
+ - !ruby/object:Gem::Version
207
+ version: '0.20'
222
208
  - !ruby/object:Gem::Dependency
223
209
  name: sqlite3
224
210
  requirement: !ruby/object:Gem::Requirement
@@ -253,14 +239,14 @@ dependencies:
253
239
  requirements:
254
240
  - - "~>"
255
241
  - !ruby/object:Gem::Version
256
- version: '2.0'
242
+ version: '2.1'
257
243
  type: :development
258
244
  prerelease: false
259
245
  version_requirements: !ruby/object:Gem::Requirement
260
246
  requirements:
261
247
  - - "~>"
262
248
  - !ruby/object:Gem::Version
263
- version: '2.0'
249
+ version: '2.1'
264
250
  - !ruby/object:Gem::Dependency
265
251
  name: thin
266
252
  requirement: !ruby/object:Gem::Requirement
@@ -320,24 +306,27 @@ files:
320
306
  homepage: https://github.com/DavyJonesLocker/client_side_validations
321
307
  licenses:
322
308
  - MIT
323
- metadata: {}
324
- post_install_message:
309
+ metadata:
310
+ bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
311
+ changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/master/CHANGELOG.md
312
+ source_code_uri: https://github.com/DavyJonesLocker/client_side_validations
313
+ post_install_message:
325
314
  rdoc_options: []
326
315
  require_paths:
327
316
  - lib
328
317
  required_ruby_version: !ruby/object:Gem::Requirement
329
318
  requirements:
330
- - - "~>"
319
+ - - ">="
331
320
  - !ruby/object:Gem::Version
332
- version: '2.3'
321
+ version: '2.4'
333
322
  required_rubygems_version: !ruby/object:Gem::Requirement
334
323
  requirements:
335
324
  - - ">="
336
325
  - !ruby/object:Gem::Version
337
326
  version: '0'
338
327
  requirements: []
339
- rubygems_version: 3.0.6
340
- signing_key:
328
+ rubygems_version: 3.0.8
329
+ signing_key:
341
330
  specification_version: 4
342
331
  summary: Client Side Validations
343
332
  test_files: []