client_side_validations 18.1.0 → 20.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e48473024c86d20fe68330cfeb13e2fdc29e4c0a8c619fb51e980d03ec8aae7
4
- data.tar.gz: 67c48790216518f72154e35c22914f4464edea104eaf1538daa772eb5b71ccfc
3
+ metadata.gz: 8d053793972cfeadf6eb418493b6290913f624536d45fd289e8186f6ed337906
4
+ data.tar.gz: 783525ab3929c02a6c3ac3af8a3fc5d0c5d549e7513fe46c56a4be8d320244e0
5
5
  SHA512:
6
- metadata.gz: 865cfdfb27838f0fc6718a4fa39ce731c05838a03e4e92d700b0f14a1cf555f782a0db1aab98d38eac8fa2d4cb807a109a551b11b454c563a6f3b60f322b19ca
7
- data.tar.gz: d649a17bf8585839bb0b2ccff97b4f63ee0ddeed9532ca5c97158db427ff8291aea086bc38f0fa440f8f8ac87c6621356b15688689c0b58bb86fc5684ee7190a
6
+ metadata.gz: 1e9f42f6a856f7ee3487ae38b552a881e7fca16fada4e11cb4027067fa0956c7c4623eb571bc0b6da6e69a0eb001b88f847ff1e0e268010cba9f7169d47ce3eb
7
+ data.tar.gz: c08fca1ba13d7bcc86e924d195950f1f05c52ba06defcb51ed287bffdd0b58a93db27734dbb61f8308c3393d2dc773146a2130388043736cebac725bbacbd312
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 20.0.0 / 2021-12-16
4
+
5
+ * [FEATURE] Add Rails 7 compatibility - POSSIBLE BREAKING CHANGE ([#862](https://github.com/DavyJonesLocker/client_side_validations/pull/862))
6
+ * [ENHANCEMENT] Update development dependencies
7
+
8
+ ## 19.1.1 / 2021-11-15
9
+
10
+ * [ENHANCEMENT] Require MFA to publish gems
11
+ * [ENHANCEMENT] Update development dependencies
12
+
13
+ ## 19.1.0 / 2021-10-05
14
+
15
+ * [FEATURE] Add Turbo compatibility ([#849](https://github.com/DavyJonesLocker/client_side_validations/pull/849))
16
+
17
+ ## 19.0.0 / 2021-10-01
18
+
19
+ * [FEATURE] Add support to `other_than` numericality validator
20
+ * [FEATURE] Drop Ruby 2.4 support
21
+ * [FEATURE] Drop Rails 5.0 and 5.1 support
22
+ * [FEATURE] Drop legacy browsers support (including IE8 and IE9)
23
+ * [FEATURE] Drop Yarn < 1.19 and Node < 12.0 support
24
+ * [FEATURE] Add JavaScript sources to node package
25
+ * [ENHANCEMENT] Minor JS Refactor
26
+ * [ENHANCEMENT] Update development dependencies
27
+ * [ENHANCEMENT] Update QUnit to 2.17.2
28
+
3
29
  ## 18.1.0 / 2021-06-13
4
30
 
5
31
  * [FEATURE] Add support to `fields` method ([#828](https://github.com/DavyJonesLocker/client_side_validations/pull/828))
data/README.md CHANGED
@@ -2,13 +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
- [![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)
5
+ [![Ruby Build Status](https://github.com/DavyJonesLocker/client_side_validations/actions/workflows/ruby.yml/badge.svg)](https://github.com/DavyJonesLocker/client_side_validations/actions)
6
+ [![JavaScript Build Status](https://github.com/DavyJonesLocker/client_side_validations/actions/workflows/javascript.yml/badge.svg)](https://github.com/DavyJonesLocker/client_side_validations/actions)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/9f9e8bb6edc92615f34e/maintainability)](https://codeclimate.com/github/DavyJonesLocker/client_side_validations/maintainability)
8
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.x applications!
11
+ `ClientSideValidations` made easy for your Rails 5.2 / 6.x / 7.0 applications!
12
12
 
13
13
  ## Project Goals ##
14
14
 
@@ -72,23 +72,23 @@ Then add the following line to your `app/javascript/packs/application.js` pack:
72
72
 
73
73
  ```js
74
74
  // If you are using `import` syntax
75
- import '@client-side-validations/client-side-validations'
75
+ import '@client-side-validations/client-side-validations/src'
76
76
 
77
77
  // If you are using `require` syntax
78
78
  require('@client-side-validations/client-side-validations')
79
79
  ```
80
80
 
81
- ##### Heads-up for Turbolinks users #####
81
+ ##### Heads-up for Turbo and Turbolinks users #####
82
82
 
83
- If you are using [Turbolinks](https://github.com/turbolinks/turbolinks) 5.2,
84
- use the require syntax and make sure that `@client-side-validations/client-side-validations`
85
- is required after`Turbolinks.start()`, so ClientSideValidations can properly
86
- attach its event handlers.
83
+ If you are using [Turbo](https://github.com/hotwired/turbo-rails), use the
84
+ `import` syntax and make sure that `@client-side-validations/client-side-validations/src`
85
+ is imported **after** `@hotwired/turbo-rails`, so ClientSideValidations can properly detect
86
+ `window.Turbo` and attach its event handlers.
87
87
 
88
- Turbolinks 5.3 automatically calls `start()`, so you can use the `import` syntax.
89
- Just make sure that `@client-side-validations/client-side-validations` is imported
90
- **after** `turbolinks`, so ClientSideValidations can properly
91
- attach its event handlers.
88
+ If you are using [Turbolinks](https://github.com/turbolinks/turbolinks) 5.2,
89
+ use the `require` syntax and make sure that `@client-side-validations/client-side-validations`
90
+ is required **after** `Turbolinks.start()`, so ClientSideValidations can properly
91
+ detect `window.Turbolinks` and attach its event handlers.
92
92
 
93
93
  #### When using Sprockets ####
94
94
 
@@ -160,8 +160,8 @@ In your `FormBuilder` you only need to enable validations:
160
160
 
161
161
  That should be enough to get you going.
162
162
 
163
- Starting from version 14.0, ClientSideValidations also supports `form_with`
164
- when used together with Rails >= 5.1. The syntax is the same as `form_for`:
163
+ Starting from version 14.0, ClientSideValidations also supports `form_with`.
164
+ The syntax is the same as `form_for`:
165
165
 
166
166
  ```erb
167
167
  <%= form_with model: @user, validate: true do |f| %>
@@ -324,11 +324,11 @@ If you need to change the markup of how the errors are rendered you can modify t
324
324
 
325
325
  ```js
326
326
  window.ClientSideValidations.formBuilders['ActionView::Helpers::FormBuilder'] = {
327
- add: function(element, settings, message) {
327
+ add: function($element, settings, message) {
328
328
  // custom add code here
329
329
  },
330
330
 
331
- remove: function(element, settings) {
331
+ remove: function($element, settings) {
332
332
  // custom remove code here
333
333
  }
334
334
  }
@@ -378,9 +378,9 @@ Finally we need to add a client side validator. This can be done by hooking into
378
378
  ```js
379
379
  // The validator variable is a JSON Object
380
380
  // The selector variable is a jQuery Object
381
- window.ClientSideValidations.validators.local['email'] = function(element, options) {
381
+ window.ClientSideValidations.validators.local['email'] = function($element, options) {
382
382
  // Your validator code goes in here
383
- if (!/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i.test(element.val())) {
383
+ if (!/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i.test($element.val())) {
384
384
  // When the value fails to pass validation you need to return the error message.
385
385
  // It can be derived from validator.message
386
386
  return options.message;
@@ -439,14 +439,14 @@ $(form).resetClientSideValidations();
439
439
 
440
440
  `ClientSideValidations` will run callbacks based upon the state of the element or form. The following callbacks are supported:
441
441
 
442
- * `ClientSideValidations.callbacks.element.after(element, eventData)`
443
- * `ClientSideValidations.callbacks.element.before(element, eventData)`
444
- * `ClientSideValidations.callbacks.element.fail(element, message, callback, eventData)`
445
- * `ClientSideValidations.callbacks.element.pass(element, callback, eventData)`
446
- * `ClientSideValidations.callbacks.form.after(form, eventData)`
447
- * `ClientSideValidations.callbacks.form.before(form, eventData)`
448
- * `ClientSideValidations.callbacks.form.fail(form, eventData)`
449
- * `ClientSideValidations.callbacks.form.pass(form, eventData)`
442
+ * `ClientSideValidations.callbacks.element.after($element, eventData)`
443
+ * `ClientSideValidations.callbacks.element.before($element, eventData)`
444
+ * `ClientSideValidations.callbacks.element.fail($element, message, callback, eventData)`
445
+ * `ClientSideValidations.callbacks.element.pass($element, callback, eventData)`
446
+ * `ClientSideValidations.callbacks.form.after($form, eventData)`
447
+ * `ClientSideValidations.callbacks.form.before($form, eventData)`
448
+ * `ClientSideValidations.callbacks.form.fail($form, eventData)`
449
+ * `ClientSideValidations.callbacks.form.pass($form, eventData)`
450
450
 
451
451
  The names of the callbacks should be pretty straight forward. For example, `ClientSideValidations.callbacks.form.fail` will be called if a form failed to validate. And `ClientSideValidations.callbacks.element.before` will be called before that particular element's validations are run.
452
452
 
@@ -458,17 +458,17 @@ Here is an example callback for sliding out the error message when the validatio
458
458
 
459
459
  ``` javascript
460
460
  // You will need to require 'jquery-ui' for this to work
461
- window.ClientSideValidations.callbacks.element.fail = function(element, message, callback) {
461
+ window.ClientSideValidations.callbacks.element.fail = function($element, message, callback) {
462
462
  callback();
463
- if (element.data('valid') !== false) {
464
- element.parent().find('.message').hide().show('slide', {direction: "left", easing: "easeOutBounce"}, 500);
463
+ if ($element.data('valid') !== false) {
464
+ $element.parent().find('.message').hide().show('slide', {direction: "left", easing: "easeOutBounce"}, 500);
465
465
  }
466
466
  }
467
467
 
468
- window.ClientSideValidations.callbacks.element.pass = function(element, callback) {
468
+ window.ClientSideValidations.callbacks.element.pass = function($element, callback) {
469
469
  // Take note how we're passing the callback to the hide()
470
470
  // method so it is run after the animation is complete.
471
- element.parent().find('.message').hide('slide', {direction: "left"}, 500, callback);
471
+ $element.parent().find('.message').hide('slide', {direction: "left"}, 500, callback);
472
472
  }
473
473
  ```
474
474
 
@@ -506,7 +506,7 @@ If for some reason you would like to manually validate the form (for example you
506
506
 
507
507
  ```js
508
508
  $input = $('#myInputField');
509
- $form = $input.closest('form');
509
+ $form = $($input[0].form);
510
510
  validators = $form[0].ClientSideValidations.settings.validators;
511
511
 
512
512
  // Validate a single field
@@ -22,7 +22,7 @@ module ClientSideValidations
22
22
  end
23
23
 
24
24
  def initialize(object_name, object, template, options)
25
- super(object_name, object, template, options)
25
+ super
26
26
  @options[:validators] = { object => {} }
27
27
  end
28
28
 
@@ -45,7 +45,7 @@ module ClientSideValidations
45
45
  def check_box(method, options = {}, checked_value = '1', unchecked_value = '0')
46
46
  build_validation_options(method, options)
47
47
  options.delete(:validate)
48
- super(method, options, checked_value, unchecked_value)
48
+ super
49
49
  end
50
50
 
51
51
  %i[collection_check_boxes collection_radio_buttons].each do |method_name|
@@ -59,7 +59,7 @@ module ClientSideValidations
59
59
  def collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
60
60
  build_validation_options(method, html_options.merge(name: options[:name]))
61
61
  html_options.delete(:validate)
62
- super(method, collection, value_method, text_method, options, html_options)
62
+ super
63
63
  end
64
64
 
65
65
  def fields_for(record_name, record_object = nil, fields_options = {}, &block)
@@ -69,42 +69,42 @@ module ClientSideValidations
69
69
  end
70
70
 
71
71
  fields_options[:validate] ||= @options[:validate] if @options[:validate] && !fields_options.key?(:validate)
72
- super(record_name, record_object, fields_options, &block)
72
+ super
73
73
  end
74
74
 
75
75
  def fields(scope = nil, model: nil, **options, &block)
76
76
  options[:validate] ||= @options[:validate] if @options[:validate] && !options.key?(:validate)
77
- super(scope, model: model, **options, &block)
77
+ super
78
78
  end
79
79
 
80
80
  def file_field(method, options = {})
81
81
  build_validation_options(method, options)
82
82
  options.delete(:validate)
83
- super(method, options)
83
+ super
84
84
  end
85
85
 
86
86
  def grouped_collection_select(method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
87
87
  build_validation_options(method, html_options.merge(name: options[:name]))
88
88
  html_options.delete(:validate)
89
- super(method, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options)
89
+ super
90
90
  end
91
91
 
92
92
  def radio_button(method, tag_value, options = {})
93
93
  build_validation_options(method, options)
94
94
  options.delete(:validate)
95
- super(method, tag_value, options)
95
+ super
96
96
  end
97
97
 
98
98
  def select(method, choices = nil, options = {}, html_options = {}, &block)
99
99
  build_validation_options(method, html_options.merge(name: options[:name]))
100
100
  html_options.delete(:validate)
101
- super(method, choices, options, html_options, &block)
101
+ super
102
102
  end
103
103
 
104
104
  def time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
105
105
  build_validation_options(method, html_options.merge(name: options[:name]))
106
106
  html_options.delete(:validate)
107
- super(method, priority_zones, options, html_options)
107
+ super
108
108
  end
109
109
 
110
110
  private
@@ -15,35 +15,41 @@ module ClientSideValidations
15
15
  # So we basically reimplement the whole form_for method
16
16
  raise ArgumentError, 'Missing block' unless block
17
17
 
18
- html_options = options[:html] ||= {}
18
+ options[:html] ||= {}
19
19
 
20
20
  # Moving the switch statement to another method to
21
21
  # lower complexity
22
- object, object_name = check_record(record, options)
22
+ model, object_name = check_record(record, options)
23
23
 
24
- @validators = {}
24
+ remote = options.delete(:remote)
25
25
 
26
- apply_html_options! options, html_options
27
-
28
- builder = instantiate_builder(object_name, object, options)
29
- output = capture(builder, &block)
30
- html_options[:multipart] ||= builder.multipart?
26
+ if remote && !embed_authenticity_token_in_remote_forms && options[:authenticity_token].blank?
27
+ options[:authenticity_token] = false
28
+ end
31
29
 
32
- build_bound_validators! options
30
+ options[:model] = model
31
+ options[:scope] = object_name
32
+ options[:local] = !remote
33
+ options[:skip_default_ids] = false
34
+ options[:allow_method_names_outside_object] = options.fetch(:allow_method_names_outside_object, false)
33
35
 
34
- apply_csv_html_options! html_options, options, builder
35
- html_options = html_options_for_form(options[:url] || {}, html_options)
36
- form_tag_with_body(html_options, output)
36
+ form_with(**options, &block)
37
37
  end
38
38
 
39
- def apply_form_for_options!(record, object, options)
40
- super
39
+ def apply_csv_form_for_options!(record, object, options)
41
40
  options[:html][:validate] = true if options[:validate]
41
+
42
+ if method(:apply_form_for_options!).arity == 2
43
+ apply_form_for_options! object, options
44
+ else
45
+ apply_form_for_options! record, object, options
46
+ end
42
47
  end
43
48
 
44
49
  def fields_for(record_name, record_object = nil, options = {}, &block)
45
50
  # Order matters here. Rails mutates the `options` object
46
- output = super
51
+ builder = instantiate_builder(record_name, record_object, options)
52
+ output = capture(builder, &block)
47
53
 
48
54
  build_bound_validators! options
49
55
 
@@ -61,10 +67,10 @@ module ClientSideValidations
61
67
  raise ArgumentError, 'First argument in form cannot contain nil or be empty' unless object
62
68
 
63
69
  object_name = options[:as] || model_name_from_record_or_class(object).param_key
64
- apply_form_for_options!(record, object, options)
70
+ apply_csv_form_for_options!(record, object, options)
65
71
  end
66
72
 
67
- [object, object_name]
73
+ [record, object_name]
68
74
  end
69
75
 
70
76
  def build_bound_validators!(options)
@@ -121,19 +127,8 @@ module ClientSideValidations
121
127
  end
122
128
  end
123
129
 
124
- def apply_html_options!(options, html_options)
125
- # Turn off HTML5 validations
126
- html_options[:novalidate] = 'novalidate'
127
-
128
- html_options[:data] = options.delete(:data) if options.key?(:data)
129
- html_options[:remote] = options.delete(:remote) if options.key?(:remote)
130
- html_options[:method] = options.delete(:method) if options.key?(:method)
131
- html_options[:enforce_utf8] = options.delete(:enforce_utf8) if options.key?(:enforce_utf8)
132
- html_options[:authenticity_token] = options.delete(:authenticity_token)
133
- end
134
-
135
130
  def apply_csv_html_options!(html_options, options, builder)
136
- html_options.delete :validate
131
+ html_options.delete 'validate'
137
132
 
138
133
  csv_options = {
139
134
  html_settings: builder.client_side_form_settings(options, self),
@@ -27,11 +27,6 @@ module ClientSideValidations
27
27
  else
28
28
  raise ArgumentError, 'Missing argument'
29
29
  end
30
- when String
31
- # rubocop:disable Security/Eval, Style/DocumentDynamicEvalDefinition
32
- l = eval("->(value) { #{conditional} }", binding, __FILE__, __LINE__)
33
- # rubocop:enable Security/Eval, Style/DocumentDynamicEvalDefinition
34
- instance_exec(nil, &l)
35
30
  when Symbol
36
31
  send conditional
37
32
  else
@@ -18,19 +18,20 @@ module ClientSideValidations
18
18
  private
19
19
 
20
20
  def build_client_side_hash(model, attribute, options)
21
- callbacks_options =
22
- if Rails.version >= '6.1'
23
- ::ActiveModel::Error::CALLBACKS_OPTIONS
24
- else
25
- ::ActiveModel::Errors::CALLBACKS_OPTIONS
26
- end
27
-
28
21
  { message: model.errors.generate_message(attribute, message_type, options) }.merge(options.except(*callbacks_options - %i[allow_blank if unless]))
29
22
  end
30
23
 
31
24
  def message_type
32
25
  kind
33
26
  end
27
+
28
+ def callbacks_options
29
+ if defined?(::ActiveModel::Errors::CALLBACKS_OPTIONS)
30
+ ::ActiveModel::Errors::CALLBACKS_OPTIONS
31
+ else
32
+ ::ActiveModel::Error::CALLBACKS_OPTIONS
33
+ end
34
+ end
34
35
  end
35
36
 
36
37
  module Validations
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClientSideValidations
4
- VERSION = '18.1.0'
4
+ VERSION = '20.0.0'
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.5 (https://github.com/DavyJonesLocker/client_side_validations)
2
+ * Client Side Validations JS - v0.3.0 (https://github.com/DavyJonesLocker/client_side_validations)
3
3
  * Copyright (c) 2021 Geremia Taglialatela, Brian Cardarella
4
4
  * Licensed under MIT (https://opensource.org/licenses/mit-license.php)
5
5
  */
@@ -7,46 +7,40 @@
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 = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ClientSideValidations = factory(global.$));
11
- }(this, (function ($) { 'use strict';
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ClientSideValidations = factory(global.jQuery));
11
+ })(this, (function (jQuery) { 'use strict';
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
- var $__default = /*#__PURE__*/_interopDefaultLegacy($);
15
+ var jQuery__default = /*#__PURE__*/_interopDefaultLegacy(jQuery);
16
16
 
17
17
  function _typeof(obj) {
18
18
  "@babel/helpers - typeof";
19
19
 
20
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
21
- _typeof = function (obj) {
22
- return typeof obj;
23
- };
24
- } else {
25
- _typeof = function (obj) {
26
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
27
- };
28
- }
29
-
30
- return _typeof(obj);
20
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
21
+ return typeof obj;
22
+ } : function (obj) {
23
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
24
+ }, _typeof(obj);
31
25
  }
32
26
 
33
27
  var ClientSideValidations = {
34
28
  callbacks: {
35
29
  element: {
36
- after: function after(element, eventData) {},
37
- before: function before(element, eventData) {},
38
- fail: function fail(element, message, addError, eventData) {
30
+ after: function after($element, eventData) {},
31
+ before: function before($element, eventData) {},
32
+ fail: function fail($element, message, addError, eventData) {
39
33
  return addError();
40
34
  },
41
- pass: function pass(element, removeError, eventData) {
35
+ pass: function pass($element, removeError, eventData) {
42
36
  return removeError();
43
37
  }
44
38
  },
45
39
  form: {
46
- after: function after(form, eventData) {},
47
- before: function before(form, eventData) {},
48
- fail: function fail(form, eventData) {},
49
- pass: function pass(form, eventData) {}
40
+ after: function after($form, eventData) {},
41
+ before: function before($form, eventData) {},
42
+ fail: function fail($form, eventData) {},
43
+ pass: function pass($form, eventData) {}
50
44
  }
51
45
  },
52
46
  eventsToBind: {
@@ -80,52 +74,52 @@
80
74
  input: function input(form) {
81
75
  return {
82
76
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
83
- $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
77
+ jQuery__default["default"](this).isValid(form.ClientSideValidations.settings.validators);
84
78
  },
85
79
  'change.ClientSideValidations': function changeClientSideValidations() {
86
- $__default['default'](this).data('changed', true);
80
+ jQuery__default["default"](this).data('changed', true);
87
81
  },
88
82
  'element:validate:after.ClientSideValidations': function elementValidateAfterClientSideValidations(eventData) {
89
- ClientSideValidations.callbacks.element.after($__default['default'](this), eventData);
83
+ ClientSideValidations.callbacks.element.after(jQuery__default["default"](this), eventData);
90
84
  },
91
85
  'element:validate:before.ClientSideValidations': function elementValidateBeforeClientSideValidations(eventData) {
92
- ClientSideValidations.callbacks.element.before($__default['default'](this), eventData);
86
+ ClientSideValidations.callbacks.element.before(jQuery__default["default"](this), eventData);
93
87
  },
94
88
  'element:validate:fail.ClientSideValidations': function elementValidateFailClientSideValidations(eventData, message) {
95
- var $element = $__default['default'](this);
89
+ var $element = jQuery__default["default"](this);
96
90
  ClientSideValidations.callbacks.element.fail($element, message, function () {
97
- return form.ClientSideValidations.addError($element, message);
91
+ form.ClientSideValidations.addError($element, message);
98
92
  }, eventData);
99
93
  },
100
94
  'element:validate:pass.ClientSideValidations': function elementValidatePassClientSideValidations(eventData) {
101
- var $element = $__default['default'](this);
95
+ var $element = jQuery__default["default"](this);
102
96
  ClientSideValidations.callbacks.element.pass($element, function () {
103
- return form.ClientSideValidations.removeError($element);
97
+ form.ClientSideValidations.removeError($element);
104
98
  }, eventData);
105
99
  }
106
100
  };
107
101
  },
108
- inputConfirmation: function inputConfirmation(element, form) {
102
+ inputConfirmation: function inputConfirmation($element, form) {
109
103
  return {
110
104
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
111
- element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
105
+ $element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
112
106
  },
113
107
  'keyup.ClientSideValidations': function keyupClientSideValidations() {
114
- element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
108
+ $element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
115
109
  }
116
110
  };
117
111
  }
118
112
  },
119
113
  enablers: {
120
114
  form: function form(_form2) {
121
- var $form = $__default['default'](_form2);
115
+ var $form = jQuery__default["default"](_form2);
122
116
  _form2.ClientSideValidations = {
123
117
  settings: $form.data('clientSideValidations'),
124
- addError: function addError(element, message) {
125
- return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add(element, _form2.ClientSideValidations.settings.html_settings, message);
118
+ addError: function addError($element, message) {
119
+ return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add($element, _form2.ClientSideValidations.settings.html_settings, message);
126
120
  },
127
- removeError: function removeError(element) {
128
- return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].remove(element, _form2.ClientSideValidations.settings.html_settings);
121
+ removeError: function removeError($element) {
122
+ return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].remove($element, _form2.ClientSideValidations.settings.html_settings);
129
123
  }
130
124
  };
131
125
  var eventsToBind = ClientSideValidations.eventsToBind.form(_form2, $form);
@@ -140,31 +134,31 @@
140
134
  });
141
135
  },
142
136
  input: function input(_input) {
143
- var $input = $__default['default'](_input);
137
+ var $input = jQuery__default["default"](_input);
144
138
  var form = _input.form;
145
- var $form = $__default['default'](form);
139
+ var $form = jQuery__default["default"](form);
146
140
  var eventsToBind = ClientSideValidations.eventsToBind.input(form);
147
141
 
148
142
  for (var eventName in eventsToBind) {
149
143
  var eventFunction = eventsToBind[eventName];
150
144
  $input.filter(':not(:radio):not([id$=_confirmation])').each(function () {
151
- return $__default['default'](this).attr('data-validate', true);
145
+ jQuery__default["default"](this).attr('data-validate', true);
152
146
  }).on(eventName, eventFunction);
153
147
  }
154
148
 
155
149
  $input.filter(':checkbox').on('change.ClientSideValidations', function () {
156
- $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
150
+ jQuery__default["default"](this).isValid(form.ClientSideValidations.settings.validators);
157
151
  });
158
152
  $input.filter('[id$=_confirmation]').each(function () {
159
- var $element = $__default['default'](this);
160
- var $elementToConfirm = $form.find('#' + this.id.match(/(.+)_confirmation/)[1] + ':input');
153
+ var $element = jQuery__default["default"](this);
154
+ var $elementToConfirm = $form.find("#".concat(this.id.match(/(.+)_confirmation/)[1], ":input"));
161
155
 
162
156
  if ($elementToConfirm.length) {
163
157
  var _eventsToBind = ClientSideValidations.eventsToBind.inputConfirmation($elementToConfirm, form);
164
158
 
165
159
  for (var _eventName in _eventsToBind) {
166
160
  var _eventFunction = _eventsToBind[_eventName];
167
- $__default['default']('#' + $element.attr('id')).on(_eventName, _eventFunction);
161
+ jQuery__default["default"]("#".concat($element.attr('id'))).on(_eventName, _eventFunction);
168
162
  }
169
163
  }
170
164
  });
@@ -172,48 +166,48 @@
172
166
  },
173
167
  formBuilders: {
174
168
  'ActionView::Helpers::FormBuilder': {
175
- add: function add(element, settings, message) {
176
- var form = $__default['default'](element[0].form);
169
+ add: function add($element, settings, message) {
170
+ var $form = jQuery__default["default"]($element[0].form);
177
171
 
178
- if (element.data('valid') !== false && form.find("label.message[for='" + element.attr('id') + "']")[0] == null) {
179
- var inputErrorField = $__default['default'](settings.input_tag);
180
- var labelErrorField = $__default['default'](settings.label_tag);
181
- var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
172
+ if ($element.data('valid') !== false && $form.find("label.message[for=\"".concat($element.attr('id'), "\"]"))[0] == null) {
173
+ var $inputErrorField = jQuery__default["default"](settings.input_tag);
174
+ var $labelErrorField = jQuery__default["default"](settings.label_tag);
175
+ var $label = $form.find("label[for=\"".concat($element.attr('id'), "\"]:not(.message)"));
182
176
 
183
- if (element.attr('autofocus')) {
184
- element.attr('autofocus', false);
177
+ if ($element.attr('autofocus')) {
178
+ $element.attr('autofocus', false);
185
179
  }
186
180
 
187
- element.before(inputErrorField);
188
- inputErrorField.find('span#input_tag').replaceWith(element);
189
- inputErrorField.find('label.message').attr('for', element.attr('id'));
190
- labelErrorField.find('label.message').attr('for', element.attr('id'));
191
- labelErrorField.insertAfter(label);
192
- labelErrorField.find('label#label_tag').replaceWith(label);
181
+ $element.before($inputErrorField);
182
+ $inputErrorField.find('span#input_tag').replaceWith($element);
183
+ $inputErrorField.find('label.message').attr('for', $element.attr('id'));
184
+ $labelErrorField.find('label.message').attr('for', $element.attr('id'));
185
+ $labelErrorField.insertAfter($label);
186
+ $labelErrorField.find('label#label_tag').replaceWith($label);
193
187
  }
194
188
 
195
- form.find("label.message[for='" + element.attr('id') + "']").text(message);
189
+ $form.find("label.message[for=\"".concat($element.attr('id'), "\"]")).text(message);
196
190
  },
197
- remove: function remove(element, settings) {
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, '.'));
201
- var label = form.find("label[for='" + element.attr('id') + "']:not(.message)");
202
- var labelErrorFieldClass = $__default['default'](settings.label_tag).attr('class');
203
- var labelErrorField = label.closest('.' + labelErrorFieldClass.replace(/ /g, '.'));
204
-
205
- if (inputErrorField[0]) {
206
- inputErrorField.find('#' + element.attr('id')).detach();
207
- inputErrorField.replaceWith(element);
208
- label.detach();
209
- labelErrorField.replaceWith(label);
191
+ remove: function remove($element, settings) {
192
+ var $form = jQuery__default["default"]($element[0].form);
193
+ var $inputErrorFieldClass = jQuery__default["default"](settings.input_tag).attr('class');
194
+ var $inputErrorField = $element.closest(".".concat($inputErrorFieldClass.replace(/ /g, '.')));
195
+ var $label = $form.find("label[for=\"".concat($element.attr('id'), "\"]:not(.message)"));
196
+ var $labelErrorFieldClass = jQuery__default["default"](settings.label_tag).attr('class');
197
+ var $labelErrorField = $label.closest(".".concat($labelErrorFieldClass.replace(/ /g, '.')));
198
+
199
+ if ($inputErrorField[0]) {
200
+ $inputErrorField.find("#".concat($element.attr('id'))).detach();
201
+ $inputErrorField.replaceWith($element);
202
+ $label.detach();
203
+ $labelErrorField.replaceWith($label);
210
204
  }
211
205
  }
212
206
  }
213
207
  },
214
208
  patterns: {
215
209
  numericality: {
216
- "default": /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
210
+ default: /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
217
211
  only_integer: /^[+-]?\d+$/
218
212
  }
219
213
  },
@@ -224,13 +218,13 @@
224
218
  },
225
219
  validators: {
226
220
  all: function all() {
227
- return $__default['default'].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
221
+ return jQuery__default["default"].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
228
222
  },
229
223
  local: {},
230
224
  remote: {}
231
225
  },
232
226
  disable: function disable(target) {
233
- var $target = $__default['default'](target);
227
+ var $target = jQuery__default["default"](target);
234
228
  $target.off('.ClientSideValidations');
235
229
 
236
230
  if ($target.is('form')) {
@@ -238,29 +232,37 @@
238
232
  } else {
239
233
  $target.removeData(['changed', 'valid']);
240
234
  $target.filter(':input').each(function () {
241
- $__default['default'](this).removeAttr('data-validate');
235
+ jQuery__default["default"](this).removeAttr('data-validate');
242
236
  });
243
237
  }
244
238
  },
245
239
  reset: function reset(form) {
246
- var $form = $__default['default'](form);
240
+ var $form = jQuery__default["default"](form);
247
241
  ClientSideValidations.disable(form);
248
242
 
249
243
  for (var key in form.ClientSideValidations.settings.validators) {
250
- form.ClientSideValidations.removeError($form.find("[name='" + key + "']"));
244
+ form.ClientSideValidations.removeError($form.find("[name=\"".concat(key, "\"]")));
251
245
  }
252
246
 
253
247
  ClientSideValidations.enablers.form(form);
254
248
  },
249
+ initializeOnEvent: function initializeOnEvent() {
250
+ if (window.Turbo != null) {
251
+ return 'turbo:load';
252
+ } else if (window.Turbolinks != null && window.Turbolinks.supported) {
253
+ return window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
254
+ }
255
+ },
255
256
  start: function start() {
256
- if (window.Turbolinks != null && window.Turbolinks.supported) {
257
- var initializeOnEvent = window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
258
- $__default['default'](document).on(initializeOnEvent, function () {
259
- return $__default['default'](ClientSideValidations.selectors.forms).validate();
257
+ var initializeOnEvent = ClientSideValidations.initializeOnEvent();
258
+
259
+ if (initializeOnEvent != null) {
260
+ jQuery__default["default"](document).on(initializeOnEvent, function () {
261
+ return jQuery__default["default"](ClientSideValidations.selectors.forms).validate();
260
262
  });
261
263
  } else {
262
- $__default['default'](function () {
263
- return $__default['default'](ClientSideValidations.selectors.forms).validate();
264
+ jQuery__default["default"](function () {
265
+ return jQuery__default["default"](ClientSideValidations.selectors.forms).validate();
264
266
  });
265
267
  }
266
268
  }
@@ -275,26 +277,22 @@
275
277
 
276
278
  return false;
277
279
  };
278
- var valueIsPresent = function valueIsPresent(value) {
280
+ var isValuePresent = function isValuePresent(value) {
279
281
  return !/^\s*$/.test(value || '');
280
282
  };
281
283
 
282
- var absenceLocalValidator = function absenceLocalValidator(element, options) {
283
- if (valueIsPresent(element.val())) {
284
+ var absenceLocalValidator = function absenceLocalValidator($element, options) {
285
+ if (isValuePresent($element.val())) {
284
286
  return options.message;
285
287
  }
286
288
  };
287
- var presenceLocalValidator = function presenceLocalValidator(element, options) {
288
- if (!valueIsPresent(element.val())) {
289
+ var presenceLocalValidator = function presenceLocalValidator($element, options) {
290
+ if (!isValuePresent($element.val())) {
289
291
  return options.message;
290
292
  }
291
293
  };
292
294
 
293
295
  var DEFAULT_ACCEPT_OPTION = ['1', true];
294
- Array.isArray || (Array.isArray = function (a) {
295
- var object = {};
296
- return '' + a !== a && object.toString.call(a) === '[object Array]';
297
- });
298
296
 
299
297
  var isTextAccepted = function isTextAccepted(value, acceptOption) {
300
298
  if (!acceptOption) {
@@ -308,15 +306,15 @@
308
306
  return value === acceptOption;
309
307
  };
310
308
 
311
- var acceptanceLocalValidator = function acceptanceLocalValidator(element, options) {
309
+ var acceptanceLocalValidator = function acceptanceLocalValidator($element, options) {
312
310
  var valid = true;
313
311
 
314
- if (element.attr('type') === 'checkbox') {
315
- valid = element.prop('checked');
312
+ if ($element.attr('type') === 'checkbox') {
313
+ valid = $element.prop('checked');
316
314
  }
317
315
 
318
- if (element.attr('type') === 'text') {
319
- valid = isTextAccepted(element.val(), options.accept);
316
+ if ($element.attr('type') === 'text') {
317
+ valid = isTextAccepted($element.val(), options.accept);
320
318
  }
321
319
 
322
320
  if (!valid) {
@@ -332,14 +330,14 @@
332
330
  return withOptions && isMatching(value, withOptions) || withoutOptions && !isMatching(value, withoutOptions);
333
331
  };
334
332
 
335
- var formatLocalValidator = function formatLocalValidator(element, options) {
336
- var value = element.val();
333
+ var formatLocalValidator = function formatLocalValidator($element, options) {
334
+ var value = $element.val();
337
335
 
338
- if (options.allow_blank && !valueIsPresent(value)) {
336
+ if (options.allow_blank && !isValuePresent(value)) {
339
337
  return;
340
338
  }
341
339
 
342
- if (!hasValidFormat(value, options["with"], options.without)) {
340
+ if (!hasValidFormat(value, options.with, options.without)) {
343
341
  return options.message;
344
342
  }
345
343
  };
@@ -365,6 +363,9 @@
365
363
  },
366
364
  odd: function odd(a) {
367
365
  return parseInt(a, 10) % 2 === 1;
366
+ },
367
+ other_than: function other_than(a, b) {
368
+ return parseFloat(a) !== parseFloat(b);
368
369
  }
369
370
  };
370
371
 
@@ -373,11 +374,11 @@
373
374
  return validationOption;
374
375
  }
375
376
 
376
- var validationElement = $form.find('[name*=' + validationOption + ']');
377
+ var validationElement = $form.find("[name*=\"".concat(validationOption, "\"]"));
377
378
 
378
379
  if (validationElement.length === 1) {
379
380
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
380
- var otherFormattedValue = $__default['default'].trim(validationElement.val()).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
381
+ var otherFormattedValue = jQuery__default["default"].trim(validationElement.val()).replace(new RegExp("\\".concat(numberFormat.separator), 'g'), '.');
381
382
 
382
383
  if (!isNaN(parseFloat(otherFormattedValue))) {
383
384
  return otherFormattedValue;
@@ -414,23 +415,23 @@
414
415
  return options.messages.only_integer;
415
416
  }
416
417
 
417
- if (!ClientSideValidations.patterns.numericality["default"].test(formattedValue)) {
418
+ if (!ClientSideValidations.patterns.numericality.default.test(formattedValue)) {
418
419
  return options.messages.numericality;
419
420
  }
420
421
 
421
422
  return runFunctionValidations(formattedValue, $form, options);
422
423
  };
423
424
 
424
- var numericalityLocalValidator = function numericalityLocalValidator(element, options) {
425
- var value = element.val();
425
+ var numericalityLocalValidator = function numericalityLocalValidator($element, options) {
426
+ var value = $element.val();
426
427
 
427
- if (options.allow_blank && !valueIsPresent(value)) {
428
+ if (options.allow_blank && !isValuePresent(value)) {
428
429
  return;
429
430
  }
430
431
 
431
- var $form = $__default['default'](element[0].form);
432
+ var $form = jQuery__default["default"]($element[0].form);
432
433
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
433
- var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
434
+ var formattedValue = jQuery__default["default"].trim(value).replace(new RegExp("\\".concat(numberFormat.separator), 'g'), '.');
434
435
  return runValidations$1(formattedValue, $form, options);
435
436
  };
436
437
 
@@ -457,10 +458,10 @@
457
458
  }
458
459
  };
459
460
 
460
- var lengthLocalValidator = function lengthLocalValidator(element, options) {
461
- var value = element.val();
461
+ var lengthLocalValidator = function lengthLocalValidator($element, options) {
462
+ var value = $element.val();
462
463
 
463
- if (options.allow_blank && !valueIsPresent(value)) {
464
+ if (options.allow_blank && !isValuePresent(value)) {
464
465
  return;
465
466
  }
466
467
 
@@ -482,29 +483,31 @@
482
483
  };
483
484
 
484
485
  var isIncluded = function isIncluded(value, options, allowBlank) {
485
- if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) {
486
+ if ((options.allow_blank && !isValuePresent(value)) === allowBlank) {
486
487
  return true;
487
488
  }
488
489
 
489
- return options["in"] && isInList(value, options["in"]) || options.range && isInRange(value, options.range);
490
+ return options.in && isInList(value, options.in) || options.range && isInRange(value, options.range);
490
491
  };
491
492
 
492
- var exclusionLocalValidator = function exclusionLocalValidator(element, options) {
493
- var value = element.val();
493
+ var exclusionLocalValidator = function exclusionLocalValidator($element, options) {
494
+ var value = $element.val();
494
495
 
495
- if (isIncluded(value, options, false) || !options.allow_blank && !valueIsPresent(value)) {
496
+ if (isIncluded(value, options, false) || !options.allow_blank && !isValuePresent(value)) {
496
497
  return options.message;
497
498
  }
498
499
  };
499
- var inclusionLocalValidator = function inclusionLocalValidator(element, options) {
500
- if (!isIncluded(element.val(), options, true)) {
500
+ var inclusionLocalValidator = function inclusionLocalValidator($element, options) {
501
+ var value = $element.val();
502
+
503
+ if (!isIncluded(value, options, true)) {
501
504
  return options.message;
502
505
  }
503
506
  };
504
507
 
505
- var confirmationLocalValidator = function confirmationLocalValidator(element, options) {
506
- var value = element.val();
507
- var confirmationValue = $__default['default']('#' + element.attr('id') + '_confirmation').val();
508
+ var confirmationLocalValidator = function confirmationLocalValidator($element, options) {
509
+ var value = $element.val();
510
+ var confirmationValue = jQuery__default["default"]("#".concat($element.attr('id'), "_confirmation")).val();
508
511
 
509
512
  if (!options.case_sensitive) {
510
513
  value = value.toLowerCase();
@@ -523,30 +526,30 @@
523
526
  }
524
527
 
525
528
  if (otherValue === value) {
526
- $__default['default'](currentElement).data('notLocallyUnique', true);
529
+ jQuery__default["default"](currentElement).data('notLocallyUnique', true);
527
530
  return false;
528
531
  }
529
532
 
530
- if ($__default['default'](currentElement).data('notLocallyUnique')) {
531
- $__default['default'](currentElement).removeData('notLocallyUnique').data('changed', true);
533
+ if (jQuery__default["default"](currentElement).data('notLocallyUnique')) {
534
+ jQuery__default["default"](currentElement).removeData('notLocallyUnique').data('changed', true);
532
535
  }
533
536
 
534
537
  return true;
535
538
  };
536
539
 
537
- var uniquenessLocalValidator = function uniquenessLocalValidator(element, options) {
538
- var elementName = element.attr('name');
540
+ var uniquenessLocalValidator = function uniquenessLocalValidator($element, options) {
541
+ var elementName = $element.attr('name');
539
542
  var matches = elementName.match(/^(.+_attributes\])\[\d+\](.+)$/);
540
543
 
541
544
  if (!matches) {
542
545
  return;
543
546
  }
544
547
 
545
- var form = element.closest('form');
546
- var value = element.val();
548
+ var $form = jQuery__default["default"]($element[0].form);
549
+ var value = $element.val();
547
550
  var valid = true;
548
- form.find(':input[name^="' + matches[1] + '"][name$="' + matches[2] + '"]').not(element).each(function () {
549
- var otherValue = $__default['default'](this).val();
551
+ $form.find(":input[name^=\"".concat(matches[1], "\"][name$=\"").concat(matches[2], "\"]")).not($element).each(function () {
552
+ var otherValue = jQuery__default["default"](this).val();
550
553
 
551
554
  if (!isLocallyUnique(this, value, otherValue, options.case_sensitive)) {
552
555
  valid = false;
@@ -571,12 +574,12 @@
571
574
  uniqueness: uniquenessLocalValidator
572
575
  };
573
576
 
574
- $__default['default'].fn.disableClientSideValidations = function () {
577
+ jQuery__default["default"].fn.disableClientSideValidations = function () {
575
578
  ClientSideValidations.disable(this);
576
579
  return this;
577
580
  };
578
581
 
579
- $__default['default'].fn.enableClientSideValidations = function () {
582
+ jQuery__default["default"].fn.enableClientSideValidations = function () {
580
583
  var _this = this;
581
584
 
582
585
  var selectors = {
@@ -588,7 +591,7 @@
588
591
  var enablers = selectors[selector];
589
592
 
590
593
  _this.filter(ClientSideValidations.selectors[selector]).each(function () {
591
- return ClientSideValidations.enablers[enablers](this);
594
+ ClientSideValidations.enablers[enablers](this);
592
595
  });
593
596
  };
594
597
 
@@ -599,22 +602,22 @@
599
602
  return this;
600
603
  };
601
604
 
602
- $__default['default'].fn.resetClientSideValidations = function () {
605
+ jQuery__default["default"].fn.resetClientSideValidations = function () {
603
606
  this.filter(ClientSideValidations.selectors.forms).each(function () {
604
- return ClientSideValidations.reset(this);
607
+ ClientSideValidations.reset(this);
605
608
  });
606
609
  return this;
607
610
  };
608
611
 
609
- $__default['default'].fn.validate = function () {
612
+ jQuery__default["default"].fn.validate = function () {
610
613
  this.filter(ClientSideValidations.selectors.forms).each(function () {
611
- return $__default['default'](this).enableClientSideValidations();
614
+ jQuery__default["default"](this).enableClientSideValidations();
612
615
  });
613
616
  return this;
614
617
  };
615
618
 
616
- $__default['default'].fn.isValid = function (validators) {
617
- var obj = $__default['default'](this[0]);
619
+ jQuery__default["default"].fn.isValid = function (validators) {
620
+ var obj = jQuery__default["default"](this[0]);
618
621
 
619
622
  if (obj.is('form')) {
620
623
  return validateForm(obj, validators);
@@ -625,7 +628,7 @@
625
628
 
626
629
  var cleanNestedElementName = function cleanNestedElementName(elementName, nestedMatches, validators) {
627
630
  for (var validatorName in validators) {
628
- if (validatorName.match('\\[' + nestedMatches[1] + '\\].*\\[\\]\\[' + nestedMatches[2] + '\\]$')) {
631
+ if (validatorName.match("\\[".concat(nestedMatches[1], "\\].*\\[\\]\\[").concat(nestedMatches[2], "\\]$"))) {
629
632
  elementName = elementName.replace(/\[[\da-z_]+\]\[(\w+)\]$/g, '[][$1]');
630
633
  }
631
634
  }
@@ -652,11 +655,11 @@
652
655
  return validators[cleanElementName(elementName, validators)] || {};
653
656
  };
654
657
 
655
- var validateForm = function validateForm(form, validators) {
658
+ var validateForm = function validateForm($form, validators) {
656
659
  var valid = true;
657
- form.trigger('form:validate:before.ClientSideValidations');
658
- form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
659
- if (!$__default['default'](this).isValid(validators)) {
660
+ $form.trigger('form:validate:before.ClientSideValidations');
661
+ $form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
662
+ if (!jQuery__default["default"](this).isValid(validators)) {
660
663
  valid = false;
661
664
  }
662
665
 
@@ -664,37 +667,37 @@
664
667
  });
665
668
 
666
669
  if (valid) {
667
- form.trigger('form:validate:pass.ClientSideValidations');
670
+ $form.trigger('form:validate:pass.ClientSideValidations');
668
671
  } else {
669
- form.trigger('form:validate:fail.ClientSideValidations');
672
+ $form.trigger('form:validate:fail.ClientSideValidations');
670
673
  }
671
674
 
672
- form.trigger('form:validate:after.ClientSideValidations');
675
+ $form.trigger('form:validate:after.ClientSideValidations');
673
676
  return valid;
674
677
  };
675
678
 
676
- var passElement = function passElement(element) {
677
- element.trigger('element:validate:pass.ClientSideValidations').data('valid', null);
679
+ var passElement = function passElement($element) {
680
+ $element.trigger('element:validate:pass.ClientSideValidations').data('valid', null);
678
681
  };
679
682
 
680
- var failElement = function failElement(element, message) {
681
- element.trigger('element:validate:fail.ClientSideValidations', message).data('valid', false);
683
+ var failElement = function failElement($element, message) {
684
+ $element.trigger('element:validate:fail.ClientSideValidations', message).data('valid', false);
682
685
  };
683
686
 
684
- var afterValidate = function afterValidate(element) {
685
- return element.trigger('element:validate:after.ClientSideValidations').data('valid') !== false;
687
+ var afterValidate = function afterValidate($element) {
688
+ return $element.trigger('element:validate:after.ClientSideValidations').data('valid') !== false;
686
689
  };
687
690
 
688
- var executeValidator = function executeValidator(validatorFunctions, validatorFunction, validatorOptions, element) {
691
+ var executeValidator = function executeValidator(validatorFunctions, validatorFunction, validatorOptions, $element) {
689
692
  for (var validatorOption in validatorOptions) {
690
693
  if (!validatorOptions[validatorOption]) {
691
694
  continue;
692
695
  }
693
696
 
694
- var message = validatorFunction.call(validatorFunctions, element, validatorOptions[validatorOption]);
697
+ var message = validatorFunction.call(validatorFunctions, $element, validatorOptions[validatorOption]);
695
698
 
696
699
  if (message) {
697
- failElement(element, message);
700
+ failElement($element, message);
698
701
  return false;
699
702
  }
700
703
  }
@@ -702,13 +705,13 @@
702
705
  return true;
703
706
  };
704
707
 
705
- var executeValidators = function executeValidators(validatorFunctions, element, validators) {
708
+ var executeValidators = function executeValidators(validatorFunctions, $element, validators) {
706
709
  for (var validator in validators) {
707
710
  if (!validatorFunctions[validator]) {
708
711
  continue;
709
712
  }
710
713
 
711
- if (!executeValidator(validatorFunctions, validatorFunctions[validator], validators[validator], element)) {
714
+ if (!executeValidator(validatorFunctions, validatorFunctions[validator], validators[validator], $element)) {
712
715
  return false;
713
716
  }
714
717
  }
@@ -716,11 +719,11 @@
716
719
  return true;
717
720
  };
718
721
 
719
- var isMarkedForDestroy = function isMarkedForDestroy(element) {
720
- if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
721
- var destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
722
+ var isMarkedForDestroy = function isMarkedForDestroy($element) {
723
+ if ($element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
724
+ var destroyInputName = $element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
722
725
 
723
- if ($__default['default']("input[name='" + destroyInputName + "']").val() === '1') {
726
+ if (jQuery__default["default"]("input[name=\"".concat(destroyInputName, "\"]")).val() === '1') {
724
727
  return true;
725
728
  }
726
729
  }
@@ -728,28 +731,28 @@
728
731
  return false;
729
732
  };
730
733
 
731
- var executeAllValidators = function executeAllValidators(element, validators) {
732
- if (element.data('changed') === false || element.prop('disabled')) {
734
+ var executeAllValidators = function executeAllValidators($element, validators) {
735
+ if ($element.data('changed') === false || $element.prop('disabled')) {
733
736
  return;
734
737
  }
735
738
 
736
- element.data('changed', false);
739
+ $element.data('changed', false);
737
740
 
738
- if (executeValidators(ClientSideValidations.validators.all(), element, validators)) {
739
- passElement(element);
741
+ if (executeValidators(ClientSideValidations.validators.all(), $element, validators)) {
742
+ passElement($element);
740
743
  }
741
744
  };
742
745
 
743
- var validateElement = function validateElement(element, validators) {
744
- element.trigger('element:validate:before.ClientSideValidations');
746
+ var validateElement = function validateElement($element, validators) {
747
+ $element.trigger('element:validate:before.ClientSideValidations');
745
748
 
746
- if (isMarkedForDestroy(element)) {
747
- passElement(element);
749
+ if (isMarkedForDestroy($element)) {
750
+ passElement($element);
748
751
  } else {
749
- executeAllValidators(element, validators);
752
+ executeAllValidators($element, validators);
750
753
  }
751
754
 
752
- return afterValidate(element);
755
+ return afterValidate($element);
753
756
  };
754
757
 
755
758
  if (!window.ClientSideValidations) {
@@ -770,4 +773,4 @@
770
773
 
771
774
  return ClientSideValidations;
772
775
 
773
- })));
776
+ }));
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: client_side_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 18.1.0
4
+ version: 20.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-06-13 00:00:00.000000000 Z
12
+ date: 2021-12-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -17,20 +17,20 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 5.0.0.1
20
+ version: '5.2'
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '7.0'
23
+ version: '7.1'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 5.0.0.1
30
+ version: '5.2'
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '7.0'
33
+ version: '7.1'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: js_regex
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -73,26 +73,6 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '11.1'
76
- - !ruby/object:Gem::Dependency
77
- name: coveralls_reborn
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0.21'
83
- - - "<"
84
- - !ruby/object:Gem::Version
85
- version: '0.23'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0.21'
93
- - - "<"
94
- - !ruby/object:Gem::Version
95
- version: '0.23'
96
76
  - !ruby/object:Gem::Dependency
97
77
  name: m
98
78
  requirement: !ruby/object:Gem::Requirement
@@ -127,14 +107,14 @@ dependencies:
127
107
  requirements:
128
108
  - - "~>"
129
109
  - !ruby/object:Gem::Version
130
- version: '1.12'
110
+ version: '1.13'
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: '1.12'
117
+ version: '1.13'
138
118
  - !ruby/object:Gem::Dependency
139
119
  name: rake
140
120
  requirement: !ruby/object:Gem::Requirement
@@ -153,22 +133,30 @@ dependencies:
153
133
  name: simplecov
154
134
  requirement: !ruby/object:Gem::Requirement
155
135
  requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- version: 0.18.5
159
- - - "<"
136
+ - - "~>"
160
137
  - !ruby/object:Gem::Version
161
- version: '0.22'
138
+ version: 0.21.2
162
139
  type: :development
163
140
  prerelease: false
164
141
  version_requirements: !ruby/object:Gem::Requirement
165
142
  requirements:
166
- - - ">="
143
+ - - "~>"
167
144
  - !ruby/object:Gem::Version
168
- version: 0.18.5
169
- - - "<"
145
+ version: 0.21.2
146
+ - !ruby/object:Gem::Dependency
147
+ name: simplecov-lcov
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.8.0
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
170
158
  - !ruby/object:Gem::Version
171
- version: '0.22'
159
+ version: 0.8.0
172
160
  - !ruby/object:Gem::Dependency
173
161
  name: sqlite3
174
162
  requirement: !ruby/object:Gem::Requirement
@@ -271,6 +259,7 @@ homepage: https://github.com/DavyJonesLocker/client_side_validations
271
259
  licenses:
272
260
  - MIT
273
261
  metadata:
262
+ rubygems_mfa_required: 'true'
274
263
  bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
275
264
  changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/main/CHANGELOG.md
276
265
  source_code_uri: https://github.com/DavyJonesLocker/client_side_validations
@@ -282,7 +271,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
271
  requirements:
283
272
  - - ">="
284
273
  - !ruby/object:Gem::Version
285
- version: '2.4'
274
+ version: '2.5'
286
275
  required_rubygems_version: !ruby/object:Gem::Requirement
287
276
  requirements:
288
277
  - - ">="