client_side_validations 17.0.0 → 18.1.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: d4bcd7d9d20f8b13d6cc5537d879d8f3f76835501d977a585898ce69ad6a6392
4
- data.tar.gz: cb32cc92ff6d52122a7c2990e7c50cf93c4d48fb3a52bfdb51ed5e3cf1c760c2
3
+ metadata.gz: 0e48473024c86d20fe68330cfeb13e2fdc29e4c0a8c619fb51e980d03ec8aae7
4
+ data.tar.gz: 67c48790216518f72154e35c22914f4464edea104eaf1538daa772eb5b71ccfc
5
5
  SHA512:
6
- metadata.gz: ea2cc5dfe1a81c6b25b7e962ea0d639e44f3e76bf392c5ce1df6db68b4658062236ec6814eb7c3d8cf9335a1f9209e4160b0acdd824b8826d1db7a9ecdde7f50
7
- data.tar.gz: 7ecf8d894db6009a43ffb0d7084cf95e1ddd67b824b170efbf3610b2cd00aca208631159bb9510f68cafd4ca028fdf4ccb36f4c9fcb83cde446f07e21edc35b1
6
+ metadata.gz: 865cfdfb27838f0fc6718a4fa39ce731c05838a03e4e92d700b0f14a1cf555f782a0db1aab98d38eac8fa2d4cb807a109a551b11b454c563a6f3b60f322b19ca
7
+ data.tar.gz: d649a17bf8585839bb0b2ccff97b4f63ee0ddeed9532ca5c97158db427ff8291aea086bc38f0fa440f8f8ac87c6621356b15688689c0b58bb86fc5684ee7190a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 18.1.0 / 2021-06-13
4
+
5
+ * [FEATURE] Add support to `fields` method ([#828](https://github.com/DavyJonesLocker/client_side_validations/pull/828))
6
+ * [ENHANCEMENT] Test against jQuery 3.6.0 by default
7
+ * [ENHANCEMENT] Test against latest Ruby versions
8
+ * [ENHANCEMENT] Update QUnit to 2.15.0
9
+
10
+ ## 18.0.0 / 2021-02-13
11
+
12
+ * [FEATURE] Add Rails 7.0.pre compatibility
13
+ * [ENHANCEMENT] Default branch is now `main` **POSSIBLE BREAKING CHANGE!**
14
+ * [ENHANCEMENT] Update QUnit to 2.14.0
15
+ * [ENHANCEMENT] Update development dependencies
16
+
17
+ ## 17.2.0 / 2020-11-03
18
+
19
+ * [FEATURE] Add Rails 6.1.0.rc1 compatibility
20
+ * [ENHANCEMENT] Update development dependencies
21
+
22
+ ## 17.1.1 / 2020-10-31
23
+
24
+ * [ENHANCEMENT] Minor code cleanup
25
+ * [ENHANCEMENT] Update development dependencies
26
+
27
+ ## 17.1.0 / 2020-10-10
28
+
29
+ * [FEATURE] Allow Ruby 3.0.0
30
+ * [ENHANCEMENT] Test against latest Ruby 2.7.2
31
+ * [ENHANCEMENT] Update QUnit to 2.11.3
32
+ * [ENHANCEMENT] Update development dependencies
33
+
3
34
  ## 17.0.0 / 2020-05-16
4
35
 
5
36
  * [FEATURE] Drop Ruby 2.3 support
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
@@ -3,12 +3,12 @@
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
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=master)](https://travis-ci.org/DavyJonesLocker/client_side_validations)
6
+ [![Build Status](https://secure.travis-ci.org/DavyJonesLocker/client_side_validations.svg?branch=main)](https://travis-ci.org/DavyJonesLocker/client_side_validations)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/9f9e8bb6edc92615f34e/maintainability)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/maintainability)
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
+ [![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)
9
9
 
10
10
 
11
- `ClientSideValidations` made easy for your Rails 5.x / Rails 6.0 applications!
11
+ `ClientSideValidations` made easy for your Rails 5.x / Rails 6.x applications!
12
12
 
13
13
  ## Project Goals ##
14
14
 
@@ -538,12 +538,12 @@ This gem follows [Semantic Versioning](https://semver.org)
538
538
  ## Want to help? ##
539
539
 
540
540
  Please do! We are always looking to improve this gem. Please see our
541
- [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)
542
542
  on how to properly submit issues and pull requests.
543
543
 
544
544
  ## Legal ##
545
545
 
546
- [DockYard](https://dockyard.com/), LLC © 2012-2019
546
+ [DockYard](https://dockyard.com/), LLC © 2012-2021
547
547
 
548
548
  [@dockyard](https://twitter.com/dockyard)
549
549
 
@@ -5,7 +5,7 @@ module ClientSideValidations
5
5
  module Helpers
6
6
  module FormBuilder
7
7
  def self.prepended(base)
8
- (base.field_helpers - %i[label check_box radio_button fields_for hidden_field file_field]).each do |selector|
8
+ (base.field_helpers - %i[label check_box radio_button fields_for fields hidden_field file_field]).each do |selector|
9
9
  base.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
10
10
  # Cannot call super here, rewrite all
11
11
  def #{selector}(method, options = {}) # def text_field(method, options = {})
@@ -72,6 +72,11 @@ module ClientSideValidations
72
72
  super(record_name, record_object, fields_options, &block)
73
73
  end
74
74
 
75
+ def fields(scope = nil, model: nil, **options, &block)
76
+ options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
77
+ super(scope, model: model, **options, &block)
78
+ end
79
+
75
80
  def file_field(method, options = {})
76
81
  build_validation_options(method, options)
77
82
  options.delete(:validate)
@@ -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,10 +98,10 @@ 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')
101
+ elsif attr.to_s.end_with?('_id')
102
102
  association_name = attr.to_s.gsub(/_id\Z/, '').to_sym
103
103
  add_validator_with_association validator_hash, validation_hash, name, association_name
104
- elsif attr.to_s.ends_with?('_ids')
104
+ elsif attr.to_s.end_with?('_ids')
105
105
  association_name = attr.to_s.gsub(/_ids\Z/, '').pluralize.to_sym
106
106
  add_validator_with_association validator_hash, validation_hash, name, association_name
107
107
  end
@@ -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
@@ -6,7 +6,15 @@ module ClientSideValidations
6
6
  @@option_map = {}
7
7
 
8
8
  def self.included(base)
9
- @@option_map.merge!(base::CHECKS.keys.inject({}) { |acc, elem| acc.merge!(elem => elem) })
9
+ checks =
10
+ if base.const_defined?('RESERVED_OPTIONS')
11
+ base::RESERVED_OPTIONS - [:only_integer]
12
+ else
13
+ base::CHECKS.keys
14
+ end
15
+
16
+ @@option_map.merge!(checks.inject({}) { |acc, elem| acc.merge!(elem => elem) })
17
+ super
10
18
  end
11
19
 
12
20
  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 = '17.0.0'
4
+ VERSION = '18.1.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 || copy_assets?
7
+ return unless instance_of?(CopyAssetsGenerator) || copy_assets?
8
8
 
9
9
  assets.each do |asset|
10
10
  source_paths << asset[:path]
@@ -1,16 +1,18 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.4 (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,11 @@
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 inputErrorFieldClass = $(settings.input_tag).attr('class');
198
+ var form = $__default['default'](element[0].form);
199
+ var inputErrorFieldClass = $__default['default'](settings.input_tag).attr('class');
198
200
  var inputErrorField = element.closest('.' + inputErrorFieldClass.replace(/ /g, '.'));
199
201
  var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
200
- var labelErrorFieldClass = $(settings.label_tag).attr('class');
202
+ var labelErrorFieldClass = $__default['default'](settings.label_tag).attr('class');
201
203
  var labelErrorField = label.closest('.' + labelErrorFieldClass.replace(/ /g, '.'));
202
204
 
203
205
  if (inputErrorField[0]) {
@@ -211,8 +213,8 @@
211
213
  },
212
214
  patterns: {
213
215
  numericality: {
214
- "default": new RegExp('^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$'),
215
- only_integer: new RegExp('^[+-]?\\d+$')
216
+ "default": /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
217
+ only_integer: /^[+-]?\d+$/
216
218
  }
217
219
  },
218
220
  selectors: {
@@ -222,13 +224,13 @@
222
224
  },
223
225
  validators: {
224
226
  all: function all() {
225
- return $.extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
227
+ return $__default['default'].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
226
228
  },
227
229
  local: {},
228
230
  remote: {}
229
231
  },
230
232
  disable: function disable(target) {
231
- var $target = $(target);
233
+ var $target = $__default['default'](target);
232
234
  $target.off('.ClientSideValidations');
233
235
 
234
236
  if ($target.is('form')) {
@@ -236,12 +238,12 @@
236
238
  } else {
237
239
  $target.removeData(['changed', 'valid']);
238
240
  $target.filter(':input').each(function () {
239
- $(this).removeAttr('data-validate');
241
+ $__default['default'](this).removeAttr('data-validate');
240
242
  });
241
243
  }
242
244
  },
243
245
  reset: function reset(form) {
244
- var $form = $(form);
246
+ var $form = $__default['default'](form);
245
247
  ClientSideValidations.disable(form);
246
248
 
247
249
  for (var key in form.ClientSideValidations.settings.validators) {
@@ -253,12 +255,12 @@
253
255
  start: function start() {
254
256
  if (window.Turbolinks != null && window.Turbolinks.supported) {
255
257
  var initializeOnEvent = window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
256
- $(document).on(initializeOnEvent, function () {
257
- return $(ClientSideValidations.selectors.forms).validate();
258
+ $__default['default'](document).on(initializeOnEvent, function () {
259
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
258
260
  });
259
261
  } else {
260
- $(function () {
261
- return $(ClientSideValidations.selectors.forms).validate();
262
+ $__default['default'](function () {
263
+ return $__default['default'](ClientSideValidations.selectors.forms).validate();
262
264
  });
263
265
  }
264
266
  }
@@ -342,7 +344,7 @@
342
344
  }
343
345
  };
344
346
 
345
- var VALIDATIONS = {
347
+ var VALIDATIONS$1 = {
346
348
  even: function even(a) {
347
349
  return parseInt(a, 10) % 2 === 0;
348
350
  },
@@ -375,7 +377,7 @@
375
377
 
376
378
  if (validationElement.length === 1) {
377
379
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
378
- 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'), '.');
379
381
 
380
382
  if (!isNaN(parseFloat(otherFormattedValue))) {
381
383
  return otherFormattedValue;
@@ -393,9 +395,9 @@
393
395
  };
394
396
 
395
397
  var runFunctionValidations = function runFunctionValidations(formattedValue, $form, options) {
396
- for (var validation in VALIDATIONS) {
398
+ for (var validation in VALIDATIONS$1) {
397
399
  var validationOption = options[validation];
398
- var validationFunction = VALIDATIONS[validation]; // Must check for null because this could be 0
400
+ var validationFunction = VALIDATIONS$1[validation]; // Must check for null because this could be 0
399
401
 
400
402
  if (validationOption == null) {
401
403
  continue;
@@ -407,7 +409,7 @@
407
409
  }
408
410
  };
409
411
 
410
- var runValidations = function runValidations(formattedValue, $form, options) {
412
+ var runValidations$1 = function runValidations(formattedValue, $form, options) {
411
413
  if (options.only_integer && !ClientSideValidations.patterns.numericality.only_integer.test(formattedValue)) {
412
414
  return options.messages.only_integer;
413
415
  }
@@ -426,13 +428,13 @@
426
428
  return;
427
429
  }
428
430
 
429
- var $form = $(element[0].form);
431
+ var $form = $__default['default'](element[0].form);
430
432
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
431
- var formattedValue = $.trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
432
- return runValidations(formattedValue, $form, options);
433
+ var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
434
+ return runValidations$1(formattedValue, $form, options);
433
435
  };
434
436
 
435
- var VALIDATIONS$1 = {
437
+ var VALIDATIONS = {
436
438
  is: function is(a, b) {
437
439
  return a === parseInt(b, 10);
438
440
  },
@@ -444,10 +446,10 @@
444
446
  }
445
447
  };
446
448
 
447
- var runValidations$1 = function runValidations(valueLength, options) {
448
- for (var validation in VALIDATIONS$1) {
449
+ var runValidations = function runValidations(valueLength, options) {
450
+ for (var validation in VALIDATIONS) {
449
451
  var validationOption = options[validation];
450
- var validationFunction = VALIDATIONS$1[validation];
452
+ var validationFunction = VALIDATIONS[validation];
451
453
 
452
454
  if (validationOption && !validationFunction(valueLength, validationOption)) {
453
455
  return options.messages[validation];
@@ -462,7 +464,7 @@
462
464
  return;
463
465
  }
464
466
 
465
- return runValidations$1(value.length, options);
467
+ return runValidations(value.length, options);
466
468
  };
467
469
 
468
470
  var isInList = function isInList(value, otherValues) {
@@ -502,7 +504,7 @@
502
504
 
503
505
  var confirmationLocalValidator = function confirmationLocalValidator(element, options) {
504
506
  var value = element.val();
505
- var confirmationValue = $('#' + element.attr('id') + '_confirmation').val();
507
+ var confirmationValue = $__default['default']('#' + element.attr('id') + '_confirmation').val();
506
508
 
507
509
  if (!options.case_sensitive) {
508
510
  value = value.toLowerCase();
@@ -521,12 +523,12 @@
521
523
  }
522
524
 
523
525
  if (otherValue === value) {
524
- $(currentElement).data('notLocallyUnique', true);
526
+ $__default['default'](currentElement).data('notLocallyUnique', true);
525
527
  return false;
526
528
  }
527
529
 
528
- if ($(currentElement).data('notLocallyUnique')) {
529
- $(currentElement).removeData('notLocallyUnique').data('changed', true);
530
+ if ($__default['default'](currentElement).data('notLocallyUnique')) {
531
+ $__default['default'](currentElement).removeData('notLocallyUnique').data('changed', true);
530
532
  }
531
533
 
532
534
  return true;
@@ -544,7 +546,7 @@
544
546
  var value = element.val();
545
547
  var valid = true;
546
548
  form.find(':input[name^="' + matches[1] + '"][name$="' + matches[2] + '"]').not(element).each(function () {
547
- var otherValue = $(this).val();
549
+ var otherValue = $__default['default'](this).val();
548
550
 
549
551
  if (!isLocallyUnique(this, value, otherValue, options.case_sensitive)) {
550
552
  valid = false;
@@ -569,12 +571,12 @@
569
571
  uniqueness: uniquenessLocalValidator
570
572
  };
571
573
 
572
- $.fn.disableClientSideValidations = function () {
574
+ $__default['default'].fn.disableClientSideValidations = function () {
573
575
  ClientSideValidations.disable(this);
574
576
  return this;
575
577
  };
576
578
 
577
- $.fn.enableClientSideValidations = function () {
579
+ $__default['default'].fn.enableClientSideValidations = function () {
578
580
  var _this = this;
579
581
 
580
582
  var selectors = {
@@ -582,7 +584,7 @@
582
584
  inputs: 'input'
583
585
  };
584
586
 
585
- var _loop = function _loop() {
587
+ var _loop = function _loop(selector) {
586
588
  var enablers = selectors[selector];
587
589
 
588
590
  _this.filter(ClientSideValidations.selectors[selector]).each(function () {
@@ -591,28 +593,28 @@
591
593
  };
592
594
 
593
595
  for (var selector in selectors) {
594
- _loop();
596
+ _loop(selector);
595
597
  }
596
598
 
597
599
  return this;
598
600
  };
599
601
 
600
- $.fn.resetClientSideValidations = function () {
602
+ $__default['default'].fn.resetClientSideValidations = function () {
601
603
  this.filter(ClientSideValidations.selectors.forms).each(function () {
602
604
  return ClientSideValidations.reset(this);
603
605
  });
604
606
  return this;
605
607
  };
606
608
 
607
- $.fn.validate = function () {
609
+ $__default['default'].fn.validate = function () {
608
610
  this.filter(ClientSideValidations.selectors.forms).each(function () {
609
- return $(this).enableClientSideValidations();
611
+ return $__default['default'](this).enableClientSideValidations();
610
612
  });
611
613
  return this;
612
614
  };
613
615
 
614
- $.fn.isValid = function (validators) {
615
- var obj = $(this[0]);
616
+ $__default['default'].fn.isValid = function (validators) {
617
+ var obj = $__default['default'](this[0]);
616
618
 
617
619
  if (obj.is('form')) {
618
620
  return validateForm(obj, validators);
@@ -654,7 +656,7 @@
654
656
  var valid = true;
655
657
  form.trigger('form:validate:before.ClientSideValidations');
656
658
  form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
657
- if (!$(this).isValid(validators)) {
659
+ if (!$__default['default'](this).isValid(validators)) {
658
660
  valid = false;
659
661
  }
660
662
 
@@ -718,7 +720,7 @@
718
720
  if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
719
721
  var destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
720
722
 
721
- if ($("input[name='" + destroyInputName + "']").val() === '1') {
723
+ if ($__default['default']("input[name='" + destroyInputName + "']").val() === '1') {
722
724
  return true;
723
725
  }
724
726
  }
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: 17.0.0
4
+ version: 18.1.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-05-16 00:00:00.000000000 Z
12
+ date: 2021-06-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,7 +30,7 @@ dependencies:
30
30
  version: 5.0.0.1
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
33
+ version: '7.0'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: js_regex
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -51,14 +51,14 @@ dependencies:
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.2'
54
+ version: '2.4'
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.2'
61
+ version: '2.4'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: byebug
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -77,16 +77,22 @@ dependencies:
77
77
  name: coveralls_reborn
78
78
  requirement: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0.21'
83
+ - - "<"
81
84
  - !ruby/object:Gem::Version
82
- version: 0.16.0
85
+ version: '0.23'
83
86
  type: :development
84
87
  prerelease: false
85
88
  version_requirements: !ruby/object:Gem::Requirement
86
89
  requirements:
87
- - - "~>"
90
+ - - ">="
88
91
  - !ruby/object:Gem::Version
89
- version: 0.16.0
92
+ version: '0.21'
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.23'
90
96
  - !ruby/object:Gem::Dependency
91
97
  name: m
92
98
  requirement: !ruby/object:Gem::Requirement
@@ -121,14 +127,14 @@ dependencies:
121
127
  requirements:
122
128
  - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '1.11'
130
+ version: '1.12'
125
131
  type: :development
126
132
  prerelease: false
127
133
  version_requirements: !ruby/object:Gem::Requirement
128
134
  requirements:
129
135
  - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '1.11'
137
+ version: '1.12'
132
138
  - !ruby/object:Gem::Dependency
133
139
  name: rake
134
140
  requirement: !ruby/object:Gem::Requirement
@@ -143,62 +149,26 @@ dependencies:
143
149
  - - "~>"
144
150
  - !ruby/object:Gem::Version
145
151
  version: '13.0'
146
- - !ruby/object:Gem::Dependency
147
- name: rubocop
148
- requirement: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 0.83.0
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: 0.83.0
160
- - !ruby/object:Gem::Dependency
161
- name: rubocop-performance
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
165
- - !ruby/object:Gem::Version
166
- version: '1.5'
167
- type: :development
168
- prerelease: false
169
- version_requirements: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
172
- - !ruby/object:Gem::Version
173
- version: '1.5'
174
- - !ruby/object:Gem::Dependency
175
- name: rubocop-rails
176
- requirement: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: '2.5'
181
- type: :development
182
- prerelease: false
183
- version_requirements: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '2.5'
188
152
  - !ruby/object:Gem::Dependency
189
153
  name: simplecov
190
154
  requirement: !ruby/object:Gem::Requirement
191
155
  requirements:
192
- - - "~>"
156
+ - - ">="
193
157
  - !ruby/object:Gem::Version
194
158
  version: 0.18.5
159
+ - - "<"
160
+ - !ruby/object:Gem::Version
161
+ version: '0.22'
195
162
  type: :development
196
163
  prerelease: false
197
164
  version_requirements: !ruby/object:Gem::Requirement
198
165
  requirements:
199
- - - "~>"
166
+ - - ">="
200
167
  - !ruby/object:Gem::Version
201
168
  version: 0.18.5
169
+ - - "<"
170
+ - !ruby/object:Gem::Version
171
+ version: '0.22'
202
172
  - !ruby/object:Gem::Dependency
203
173
  name: sqlite3
204
174
  requirement: !ruby/object:Gem::Requirement
@@ -233,16 +203,16 @@ dependencies:
233
203
  requirements:
234
204
  - - "~>"
235
205
  - !ruby/object:Gem::Version
236
- version: '2.0'
206
+ version: '2.1'
237
207
  type: :development
238
208
  prerelease: false
239
209
  version_requirements: !ruby/object:Gem::Requirement
240
210
  requirements:
241
211
  - - "~>"
242
212
  - !ruby/object:Gem::Version
243
- version: '2.0'
213
+ version: '2.1'
244
214
  - !ruby/object:Gem::Dependency
245
- name: thin
215
+ name: webrick
246
216
  requirement: !ruby/object:Gem::Requirement
247
217
  requirements:
248
218
  - - "~>"
@@ -302,15 +272,15 @@ licenses:
302
272
  - MIT
303
273
  metadata:
304
274
  bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
305
- changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/master/CHANGELOG.md
275
+ changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/main/CHANGELOG.md
306
276
  source_code_uri: https://github.com/DavyJonesLocker/client_side_validations
307
- post_install_message:
277
+ post_install_message:
308
278
  rdoc_options: []
309
279
  require_paths:
310
280
  - lib
311
281
  required_ruby_version: !ruby/object:Gem::Requirement
312
282
  requirements:
313
- - - "~>"
283
+ - - ">="
314
284
  - !ruby/object:Gem::Version
315
285
  version: '2.4'
316
286
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -319,8 +289,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
319
289
  - !ruby/object:Gem::Version
320
290
  version: '0'
321
291
  requirements: []
322
- rubygems_version: 3.1.2
323
- signing_key:
292
+ rubygems_version: 3.1.6
293
+ signing_key:
324
294
  specification_version: 4
325
295
  summary: Client Side Validations
326
296
  test_files: []