client_side_validations 17.2.0 → 19.1.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: 97a48b61499546fba6c9622072b67b61c552fbb75caf0107cc471771149b2634
4
- data.tar.gz: f594a262364d834a2eb20b6cb8c75006f08715c52970ad4b976b5a6597811a99
3
+ metadata.gz: 4e5904433f3b766e4544605c251a50c28349fbad906456b4823e19ea2700aef1
4
+ data.tar.gz: 0d3fe57c177d373237ce63c2f905fd2c907579c268e550134f3d954a2b72df61
5
5
  SHA512:
6
- metadata.gz: a8461c934cfb75e9c9be30e807d400acbeb0579b985879d0f5587809be71edd2a539c878a601ce84b7e636db08c14930a5a8112ff8302f7ee700f4d9c7773d20
7
- data.tar.gz: 8a375314404e0a025af14190a570ef23a331fb72732a3ae1e57df8a6580cf580247fcae19dff65a96104c4d5d064f0f78fae770dcf818e2e36e0b532d38d3222
6
+ metadata.gz: 51f6b2a441831cb479f267a04627badde3d6478f733b7a66792ca9df0e3f4eb403fed52210a7c2001c855b697d9cfeb14f51eb222aadc21b392bebf71d4ad903
7
+ data.tar.gz: bf6196647cba2846209dd206e2e3bc1eec79f4e07f66720996c1761670288cd8496fcef2a5e620faea34cf8225dfc2856f9eb480773755c9b28dc6acb4ab03e4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## 19.1.0 / 2021-10-05
4
+
5
+ * [FEATURE] Add Turbo compatibility ([#849](https://github.com/DavyJonesLocker/client_side_validations/pull/849))
6
+
7
+ ## 19.0.0 / 2021-10-01
8
+
9
+ * [FEATURE] Add support to `other_than` numericality validator
10
+ * [FEATURE] Drop Ruby 2.4 support
11
+ * [FEATURE] Drop Rails 5.0 and 5.1 support
12
+ * [FEATURE] Drop legacy browsers support (including IE8 and IE9)
13
+ * [FEATURE] Drop Yarn < 1.19 and Node < 12.0 support
14
+ * [FEATURE] Add JavaScript sources to node package
15
+ * [ENHANCEMENT] Minor JS Refactor
16
+ * [ENHANCEMENT] Update development dependencies
17
+ * [ENHANCEMENT] Update QUnit to 2.17.2
18
+
19
+ ## 18.1.0 / 2021-06-13
20
+
21
+ * [FEATURE] Add support to `fields` method ([#828](https://github.com/DavyJonesLocker/client_side_validations/pull/828))
22
+ * [ENHANCEMENT] Test against jQuery 3.6.0 by default
23
+ * [ENHANCEMENT] Test against latest Ruby versions
24
+ * [ENHANCEMENT] Update QUnit to 2.15.0
25
+
26
+ ## 18.0.0 / 2021-02-13
27
+
28
+ * [FEATURE] Add Rails 7.0.pre compatibility
29
+ * [ENHANCEMENT] Default branch is now `main` **POSSIBLE BREAKING CHANGE!**
30
+ * [ENHANCEMENT] Update QUnit to 2.14.0
31
+ * [ENHANCEMENT] Update development dependencies
32
+
3
33
  ## 17.2.0 / 2020-11-03
4
34
 
5
35
  * [FEATURE] Add Rails 6.1.0.rc1 compatibility
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://github.com/DavyJonesLocker/client_side_validations/actions/workflows/ruby.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
- [![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.x applications!
11
+ `ClientSideValidations` made easy for your Rails 5.2 / Rails 6.x applications!
12
12
 
13
13
  ## Project Goals ##
14
14
 
@@ -72,7 +72,7 @@ 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')
@@ -85,9 +85,9 @@ use the require syntax and make sure that `@client-side-validations/client-side-
85
85
  is required after`Turbolinks.start()`, so ClientSideValidations can properly
86
86
  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
88
+ [Turbo](https://github.com/hotwired/turbo-rails) automatically calls `start()`,
89
+ so you can use the `import` syntax. Just make sure that `@client-side-validations/client-side-validations/src`
90
+ is imported **after** `turbo`, so ClientSideValidations can properly
91
91
  attach its event handlers.
92
92
 
93
93
  #### When using Sprockets ####
@@ -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
@@ -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 &copy; 2012-2020
546
+ [DockYard](https://dockyard.com/), LLC &copy; 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
 
@@ -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)
@@ -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
@@ -6,7 +6,14 @@ 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) })
10
17
  super
11
18
  end
12
19
 
@@ -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 = '17.2.0'
4
+ VERSION = '19.1.0'
5
5
  end
@@ -1,18 +1,18 @@
1
1
  /*!
2
- * Client Side Validations JS - v0.1.5 (https://github.com/DavyJonesLocker/client_side_validations)
3
- * Copyright (c) 2020 Geremia Taglialatela, Brian Cardarella
2
+ * Client Side Validations JS - v0.3.0 (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 = 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";
@@ -33,20 +33,20 @@
33
33
  var ClientSideValidations = {
34
34
  callbacks: {
35
35
  element: {
36
- after: function after(element, eventData) {},
37
- before: function before(element, eventData) {},
38
- fail: function fail(element, message, addError, eventData) {
36
+ after: function after($element, eventData) {},
37
+ before: function before($element, eventData) {},
38
+ fail: function fail($element, message, addError, eventData) {
39
39
  return addError();
40
40
  },
41
- pass: function pass(element, removeError, eventData) {
41
+ pass: function pass($element, removeError, eventData) {
42
42
  return removeError();
43
43
  }
44
44
  },
45
45
  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) {}
46
+ after: function after($form, eventData) {},
47
+ before: function before($form, eventData) {},
48
+ fail: function fail($form, eventData) {},
49
+ pass: function pass($form, eventData) {}
50
50
  }
51
51
  },
52
52
  eventsToBind: {
@@ -80,52 +80,52 @@
80
80
  input: function input(form) {
81
81
  return {
82
82
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
83
- $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
83
+ jQuery__default["default"](this).isValid(form.ClientSideValidations.settings.validators);
84
84
  },
85
85
  'change.ClientSideValidations': function changeClientSideValidations() {
86
- $__default['default'](this).data('changed', true);
86
+ jQuery__default["default"](this).data('changed', true);
87
87
  },
88
88
  'element:validate:after.ClientSideValidations': function elementValidateAfterClientSideValidations(eventData) {
89
- ClientSideValidations.callbacks.element.after($__default['default'](this), eventData);
89
+ ClientSideValidations.callbacks.element.after(jQuery__default["default"](this), eventData);
90
90
  },
91
91
  'element:validate:before.ClientSideValidations': function elementValidateBeforeClientSideValidations(eventData) {
92
- ClientSideValidations.callbacks.element.before($__default['default'](this), eventData);
92
+ ClientSideValidations.callbacks.element.before(jQuery__default["default"](this), eventData);
93
93
  },
94
94
  'element:validate:fail.ClientSideValidations': function elementValidateFailClientSideValidations(eventData, message) {
95
- var $element = $__default['default'](this);
95
+ var $element = jQuery__default["default"](this);
96
96
  ClientSideValidations.callbacks.element.fail($element, message, function () {
97
- return form.ClientSideValidations.addError($element, message);
97
+ form.ClientSideValidations.addError($element, message);
98
98
  }, eventData);
99
99
  },
100
100
  'element:validate:pass.ClientSideValidations': function elementValidatePassClientSideValidations(eventData) {
101
- var $element = $__default['default'](this);
101
+ var $element = jQuery__default["default"](this);
102
102
  ClientSideValidations.callbacks.element.pass($element, function () {
103
- return form.ClientSideValidations.removeError($element);
103
+ form.ClientSideValidations.removeError($element);
104
104
  }, eventData);
105
105
  }
106
106
  };
107
107
  },
108
- inputConfirmation: function inputConfirmation(element, form) {
108
+ inputConfirmation: function inputConfirmation($element, form) {
109
109
  return {
110
110
  'focusout.ClientSideValidations': function focusoutClientSideValidations() {
111
- element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
111
+ $element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
112
112
  },
113
113
  'keyup.ClientSideValidations': function keyupClientSideValidations() {
114
- element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
114
+ $element.data('changed', true).isValid(form.ClientSideValidations.settings.validators);
115
115
  }
116
116
  };
117
117
  }
118
118
  },
119
119
  enablers: {
120
120
  form: function form(_form2) {
121
- var $form = $__default['default'](_form2);
121
+ var $form = jQuery__default["default"](_form2);
122
122
  _form2.ClientSideValidations = {
123
123
  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);
124
+ addError: function addError($element, message) {
125
+ return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].add($element, _form2.ClientSideValidations.settings.html_settings, message);
126
126
  },
127
- removeError: function removeError(element) {
128
- return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].remove(element, _form2.ClientSideValidations.settings.html_settings);
127
+ removeError: function removeError($element) {
128
+ return ClientSideValidations.formBuilders[_form2.ClientSideValidations.settings.html_settings.type].remove($element, _form2.ClientSideValidations.settings.html_settings);
129
129
  }
130
130
  };
131
131
  var eventsToBind = ClientSideValidations.eventsToBind.form(_form2, $form);
@@ -140,31 +140,31 @@
140
140
  });
141
141
  },
142
142
  input: function input(_input) {
143
- var $input = $__default['default'](_input);
143
+ var $input = jQuery__default["default"](_input);
144
144
  var form = _input.form;
145
- var $form = $__default['default'](form);
145
+ var $form = jQuery__default["default"](form);
146
146
  var eventsToBind = ClientSideValidations.eventsToBind.input(form);
147
147
 
148
148
  for (var eventName in eventsToBind) {
149
149
  var eventFunction = eventsToBind[eventName];
150
150
  $input.filter(':not(:radio):not([id$=_confirmation])').each(function () {
151
- return $__default['default'](this).attr('data-validate', true);
151
+ jQuery__default["default"](this).attr('data-validate', true);
152
152
  }).on(eventName, eventFunction);
153
153
  }
154
154
 
155
155
  $input.filter(':checkbox').on('change.ClientSideValidations', function () {
156
- $__default['default'](this).isValid(form.ClientSideValidations.settings.validators);
156
+ jQuery__default["default"](this).isValid(form.ClientSideValidations.settings.validators);
157
157
  });
158
158
  $input.filter('[id$=_confirmation]').each(function () {
159
- var $element = $__default['default'](this);
160
- var $elementToConfirm = $form.find('#' + this.id.match(/(.+)_confirmation/)[1] + ':input');
159
+ var $element = jQuery__default["default"](this);
160
+ var $elementToConfirm = $form.find("#".concat(this.id.match(/(.+)_confirmation/)[1], ":input"));
161
161
 
162
162
  if ($elementToConfirm.length) {
163
163
  var _eventsToBind = ClientSideValidations.eventsToBind.inputConfirmation($elementToConfirm, form);
164
164
 
165
165
  for (var _eventName in _eventsToBind) {
166
166
  var _eventFunction = _eventsToBind[_eventName];
167
- $__default['default']('#' + $element.attr('id')).on(_eventName, _eventFunction);
167
+ jQuery__default["default"]("#".concat($element.attr('id'))).on(_eventName, _eventFunction);
168
168
  }
169
169
  }
170
170
  });
@@ -172,48 +172,48 @@
172
172
  },
173
173
  formBuilders: {
174
174
  'ActionView::Helpers::FormBuilder': {
175
- add: function add(element, settings, message) {
176
- var form = $__default['default'](element[0].form);
175
+ add: function add($element, settings, message) {
176
+ var $form = jQuery__default["default"]($element[0].form);
177
177
 
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)");
178
+ if ($element.data('valid') !== false && $form.find("label.message[for=\"".concat($element.attr('id'), "\"]"))[0] == null) {
179
+ var $inputErrorField = jQuery__default["default"](settings.input_tag);
180
+ var $labelErrorField = jQuery__default["default"](settings.label_tag);
181
+ var $label = $form.find("label[for=\"".concat($element.attr('id'), "\"]:not(.message)"));
182
182
 
183
- if (element.attr('autofocus')) {
184
- element.attr('autofocus', false);
183
+ if ($element.attr('autofocus')) {
184
+ $element.attr('autofocus', false);
185
185
  }
186
186
 
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);
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);
193
193
  }
194
194
 
195
- form.find("label.message[for='" + element.attr('id') + "']").text(message);
195
+ $form.find("label.message[for=\"".concat($element.attr('id'), "\"]")).text(message);
196
196
  },
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);
197
+ remove: function remove($element, settings) {
198
+ var $form = jQuery__default["default"]($element[0].form);
199
+ var $inputErrorFieldClass = jQuery__default["default"](settings.input_tag).attr('class');
200
+ var $inputErrorField = $element.closest(".".concat($inputErrorFieldClass.replace(/ /g, '.')));
201
+ var $label = $form.find("label[for=\"".concat($element.attr('id'), "\"]:not(.message)"));
202
+ var $labelErrorFieldClass = jQuery__default["default"](settings.label_tag).attr('class');
203
+ var $labelErrorField = $label.closest(".".concat($labelErrorFieldClass.replace(/ /g, '.')));
204
+
205
+ if ($inputErrorField[0]) {
206
+ $inputErrorField.find("#".concat($element.attr('id'))).detach();
207
+ $inputErrorField.replaceWith($element);
208
+ $label.detach();
209
+ $labelErrorField.replaceWith($label);
210
210
  }
211
211
  }
212
212
  }
213
213
  },
214
214
  patterns: {
215
215
  numericality: {
216
- "default": /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
216
+ default: /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,
217
217
  only_integer: /^[+-]?\d+$/
218
218
  }
219
219
  },
@@ -224,13 +224,13 @@
224
224
  },
225
225
  validators: {
226
226
  all: function all() {
227
- return $__default['default'].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
227
+ return jQuery__default["default"].extend({}, ClientSideValidations.validators.local, ClientSideValidations.validators.remote);
228
228
  },
229
229
  local: {},
230
230
  remote: {}
231
231
  },
232
232
  disable: function disable(target) {
233
- var $target = $__default['default'](target);
233
+ var $target = jQuery__default["default"](target);
234
234
  $target.off('.ClientSideValidations');
235
235
 
236
236
  if ($target.is('form')) {
@@ -238,29 +238,37 @@
238
238
  } else {
239
239
  $target.removeData(['changed', 'valid']);
240
240
  $target.filter(':input').each(function () {
241
- $__default['default'](this).removeAttr('data-validate');
241
+ jQuery__default["default"](this).removeAttr('data-validate');
242
242
  });
243
243
  }
244
244
  },
245
245
  reset: function reset(form) {
246
- var $form = $__default['default'](form);
246
+ var $form = jQuery__default["default"](form);
247
247
  ClientSideValidations.disable(form);
248
248
 
249
249
  for (var key in form.ClientSideValidations.settings.validators) {
250
- form.ClientSideValidations.removeError($form.find("[name='" + key + "']"));
250
+ form.ClientSideValidations.removeError($form.find("[name=\"".concat(key, "\"]")));
251
251
  }
252
252
 
253
253
  ClientSideValidations.enablers.form(form);
254
254
  },
255
+ initializeOnEvent: function initializeOnEvent() {
256
+ if (window.Turbo != null) {
257
+ return 'turbo:load';
258
+ } else if (window.Turbolinks != null && window.Turbolinks.supported) {
259
+ return window.Turbolinks.EVENTS != null ? 'page:change' : 'turbolinks:load';
260
+ }
261
+ },
255
262
  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();
263
+ var initializeOnEvent = ClientSideValidations.initializeOnEvent();
264
+
265
+ if (initializeOnEvent != null) {
266
+ jQuery__default["default"](document).on(initializeOnEvent, function () {
267
+ return jQuery__default["default"](ClientSideValidations.selectors.forms).validate();
260
268
  });
261
269
  } else {
262
- $__default['default'](function () {
263
- return $__default['default'](ClientSideValidations.selectors.forms).validate();
270
+ jQuery__default["default"](function () {
271
+ return jQuery__default["default"](ClientSideValidations.selectors.forms).validate();
264
272
  });
265
273
  }
266
274
  }
@@ -275,26 +283,22 @@
275
283
 
276
284
  return false;
277
285
  };
278
- var valueIsPresent = function valueIsPresent(value) {
286
+ var isValuePresent = function isValuePresent(value) {
279
287
  return !/^\s*$/.test(value || '');
280
288
  };
281
289
 
282
- var absenceLocalValidator = function absenceLocalValidator(element, options) {
283
- if (valueIsPresent(element.val())) {
290
+ var absenceLocalValidator = function absenceLocalValidator($element, options) {
291
+ if (isValuePresent($element.val())) {
284
292
  return options.message;
285
293
  }
286
294
  };
287
- var presenceLocalValidator = function presenceLocalValidator(element, options) {
288
- if (!valueIsPresent(element.val())) {
295
+ var presenceLocalValidator = function presenceLocalValidator($element, options) {
296
+ if (!isValuePresent($element.val())) {
289
297
  return options.message;
290
298
  }
291
299
  };
292
300
 
293
301
  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
302
 
299
303
  var isTextAccepted = function isTextAccepted(value, acceptOption) {
300
304
  if (!acceptOption) {
@@ -308,15 +312,15 @@
308
312
  return value === acceptOption;
309
313
  };
310
314
 
311
- var acceptanceLocalValidator = function acceptanceLocalValidator(element, options) {
315
+ var acceptanceLocalValidator = function acceptanceLocalValidator($element, options) {
312
316
  var valid = true;
313
317
 
314
- if (element.attr('type') === 'checkbox') {
315
- valid = element.prop('checked');
318
+ if ($element.attr('type') === 'checkbox') {
319
+ valid = $element.prop('checked');
316
320
  }
317
321
 
318
- if (element.attr('type') === 'text') {
319
- valid = isTextAccepted(element.val(), options.accept);
322
+ if ($element.attr('type') === 'text') {
323
+ valid = isTextAccepted($element.val(), options.accept);
320
324
  }
321
325
 
322
326
  if (!valid) {
@@ -332,19 +336,19 @@
332
336
  return withOptions && isMatching(value, withOptions) || withoutOptions && !isMatching(value, withoutOptions);
333
337
  };
334
338
 
335
- var formatLocalValidator = function formatLocalValidator(element, options) {
336
- var value = element.val();
339
+ var formatLocalValidator = function formatLocalValidator($element, options) {
340
+ var value = $element.val();
337
341
 
338
- if (options.allow_blank && !valueIsPresent(value)) {
342
+ if (options.allow_blank && !isValuePresent(value)) {
339
343
  return;
340
344
  }
341
345
 
342
- if (!hasValidFormat(value, options["with"], options.without)) {
346
+ if (!hasValidFormat(value, options.with, options.without)) {
343
347
  return options.message;
344
348
  }
345
349
  };
346
350
 
347
- var VALIDATIONS = {
351
+ var VALIDATIONS$1 = {
348
352
  even: function even(a) {
349
353
  return parseInt(a, 10) % 2 === 0;
350
354
  },
@@ -365,6 +369,9 @@
365
369
  },
366
370
  odd: function odd(a) {
367
371
  return parseInt(a, 10) % 2 === 1;
372
+ },
373
+ other_than: function other_than(a, b) {
374
+ return parseFloat(a) !== parseFloat(b);
368
375
  }
369
376
  };
370
377
 
@@ -373,11 +380,11 @@
373
380
  return validationOption;
374
381
  }
375
382
 
376
- var validationElement = $form.find('[name*=' + validationOption + ']');
383
+ var validationElement = $form.find("[name*=\"".concat(validationOption, "\"]"));
377
384
 
378
385
  if (validationElement.length === 1) {
379
386
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
380
- var otherFormattedValue = $__default['default'].trim(validationElement.val()).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
387
+ var otherFormattedValue = jQuery__default["default"].trim(validationElement.val()).replace(new RegExp("\\".concat(numberFormat.separator), 'g'), '.');
381
388
 
382
389
  if (!isNaN(parseFloat(otherFormattedValue))) {
383
390
  return otherFormattedValue;
@@ -395,9 +402,9 @@
395
402
  };
396
403
 
397
404
  var runFunctionValidations = function runFunctionValidations(formattedValue, $form, options) {
398
- for (var validation in VALIDATIONS) {
405
+ for (var validation in VALIDATIONS$1) {
399
406
  var validationOption = options[validation];
400
- var validationFunction = VALIDATIONS[validation]; // Must check for null because this could be 0
407
+ var validationFunction = VALIDATIONS$1[validation]; // Must check for null because this could be 0
401
408
 
402
409
  if (validationOption == null) {
403
410
  continue;
@@ -409,32 +416,32 @@
409
416
  }
410
417
  };
411
418
 
412
- var runValidations = function runValidations(formattedValue, $form, options) {
419
+ var runValidations$1 = function runValidations(formattedValue, $form, options) {
413
420
  if (options.only_integer && !ClientSideValidations.patterns.numericality.only_integer.test(formattedValue)) {
414
421
  return options.messages.only_integer;
415
422
  }
416
423
 
417
- if (!ClientSideValidations.patterns.numericality["default"].test(formattedValue)) {
424
+ if (!ClientSideValidations.patterns.numericality.default.test(formattedValue)) {
418
425
  return options.messages.numericality;
419
426
  }
420
427
 
421
428
  return runFunctionValidations(formattedValue, $form, options);
422
429
  };
423
430
 
424
- var numericalityLocalValidator = function numericalityLocalValidator(element, options) {
425
- var value = element.val();
431
+ var numericalityLocalValidator = function numericalityLocalValidator($element, options) {
432
+ var value = $element.val();
426
433
 
427
- if (options.allow_blank && !valueIsPresent(value)) {
434
+ if (options.allow_blank && !isValuePresent(value)) {
428
435
  return;
429
436
  }
430
437
 
431
- var $form = $__default['default'](element[0].form);
438
+ var $form = jQuery__default["default"]($element[0].form);
432
439
  var numberFormat = $form[0].ClientSideValidations.settings.number_format;
433
- var formattedValue = $__default['default'].trim(value).replace(new RegExp('\\' + numberFormat.separator, 'g'), '.');
434
- return runValidations(formattedValue, $form, options);
440
+ var formattedValue = jQuery__default["default"].trim(value).replace(new RegExp("\\".concat(numberFormat.separator), 'g'), '.');
441
+ return runValidations$1(formattedValue, $form, options);
435
442
  };
436
443
 
437
- var VALIDATIONS$1 = {
444
+ var VALIDATIONS = {
438
445
  is: function is(a, b) {
439
446
  return a === parseInt(b, 10);
440
447
  },
@@ -446,10 +453,10 @@
446
453
  }
447
454
  };
448
455
 
449
- var runValidations$1 = function runValidations(valueLength, options) {
450
- for (var validation in VALIDATIONS$1) {
456
+ var runValidations = function runValidations(valueLength, options) {
457
+ for (var validation in VALIDATIONS) {
451
458
  var validationOption = options[validation];
452
- var validationFunction = VALIDATIONS$1[validation];
459
+ var validationFunction = VALIDATIONS[validation];
453
460
 
454
461
  if (validationOption && !validationFunction(valueLength, validationOption)) {
455
462
  return options.messages[validation];
@@ -457,14 +464,14 @@
457
464
  }
458
465
  };
459
466
 
460
- var lengthLocalValidator = function lengthLocalValidator(element, options) {
461
- var value = element.val();
467
+ var lengthLocalValidator = function lengthLocalValidator($element, options) {
468
+ var value = $element.val();
462
469
 
463
- if (options.allow_blank && !valueIsPresent(value)) {
470
+ if (options.allow_blank && !isValuePresent(value)) {
464
471
  return;
465
472
  }
466
473
 
467
- return runValidations$1(value.length, options);
474
+ return runValidations(value.length, options);
468
475
  };
469
476
 
470
477
  var isInList = function isInList(value, otherValues) {
@@ -482,29 +489,31 @@
482
489
  };
483
490
 
484
491
  var isIncluded = function isIncluded(value, options, allowBlank) {
485
- if ((options.allow_blank && !valueIsPresent(value)) === allowBlank) {
492
+ if ((options.allow_blank && !isValuePresent(value)) === allowBlank) {
486
493
  return true;
487
494
  }
488
495
 
489
- return options["in"] && isInList(value, options["in"]) || options.range && isInRange(value, options.range);
496
+ return options.in && isInList(value, options.in) || options.range && isInRange(value, options.range);
490
497
  };
491
498
 
492
- var exclusionLocalValidator = function exclusionLocalValidator(element, options) {
493
- var value = element.val();
499
+ var exclusionLocalValidator = function exclusionLocalValidator($element, options) {
500
+ var value = $element.val();
494
501
 
495
- if (isIncluded(value, options, false) || !options.allow_blank && !valueIsPresent(value)) {
502
+ if (isIncluded(value, options, false) || !options.allow_blank && !isValuePresent(value)) {
496
503
  return options.message;
497
504
  }
498
505
  };
499
- var inclusionLocalValidator = function inclusionLocalValidator(element, options) {
500
- if (!isIncluded(element.val(), options, true)) {
506
+ var inclusionLocalValidator = function inclusionLocalValidator($element, options) {
507
+ var value = $element.val();
508
+
509
+ if (!isIncluded(value, options, true)) {
501
510
  return options.message;
502
511
  }
503
512
  };
504
513
 
505
- var confirmationLocalValidator = function confirmationLocalValidator(element, options) {
506
- var value = element.val();
507
- var confirmationValue = $__default['default']('#' + element.attr('id') + '_confirmation').val();
514
+ var confirmationLocalValidator = function confirmationLocalValidator($element, options) {
515
+ var value = $element.val();
516
+ var confirmationValue = jQuery__default["default"]("#".concat($element.attr('id'), "_confirmation")).val();
508
517
 
509
518
  if (!options.case_sensitive) {
510
519
  value = value.toLowerCase();
@@ -523,30 +532,30 @@
523
532
  }
524
533
 
525
534
  if (otherValue === value) {
526
- $__default['default'](currentElement).data('notLocallyUnique', true);
535
+ jQuery__default["default"](currentElement).data('notLocallyUnique', true);
527
536
  return false;
528
537
  }
529
538
 
530
- if ($__default['default'](currentElement).data('notLocallyUnique')) {
531
- $__default['default'](currentElement).removeData('notLocallyUnique').data('changed', true);
539
+ if (jQuery__default["default"](currentElement).data('notLocallyUnique')) {
540
+ jQuery__default["default"](currentElement).removeData('notLocallyUnique').data('changed', true);
532
541
  }
533
542
 
534
543
  return true;
535
544
  };
536
545
 
537
- var uniquenessLocalValidator = function uniquenessLocalValidator(element, options) {
538
- var elementName = element.attr('name');
546
+ var uniquenessLocalValidator = function uniquenessLocalValidator($element, options) {
547
+ var elementName = $element.attr('name');
539
548
  var matches = elementName.match(/^(.+_attributes\])\[\d+\](.+)$/);
540
549
 
541
550
  if (!matches) {
542
551
  return;
543
552
  }
544
553
 
545
- var form = element.closest('form');
546
- var value = element.val();
554
+ var $form = jQuery__default["default"]($element[0].form);
555
+ var value = $element.val();
547
556
  var valid = true;
548
- form.find(':input[name^="' + matches[1] + '"][name$="' + matches[2] + '"]').not(element).each(function () {
549
- var otherValue = $__default['default'](this).val();
557
+ $form.find(":input[name^=\"".concat(matches[1], "\"][name$=\"").concat(matches[2], "\"]")).not($element).each(function () {
558
+ var otherValue = jQuery__default["default"](this).val();
550
559
 
551
560
  if (!isLocallyUnique(this, value, otherValue, options.case_sensitive)) {
552
561
  valid = false;
@@ -571,12 +580,12 @@
571
580
  uniqueness: uniquenessLocalValidator
572
581
  };
573
582
 
574
- $__default['default'].fn.disableClientSideValidations = function () {
583
+ jQuery__default["default"].fn.disableClientSideValidations = function () {
575
584
  ClientSideValidations.disable(this);
576
585
  return this;
577
586
  };
578
587
 
579
- $__default['default'].fn.enableClientSideValidations = function () {
588
+ jQuery__default["default"].fn.enableClientSideValidations = function () {
580
589
  var _this = this;
581
590
 
582
591
  var selectors = {
@@ -588,7 +597,7 @@
588
597
  var enablers = selectors[selector];
589
598
 
590
599
  _this.filter(ClientSideValidations.selectors[selector]).each(function () {
591
- return ClientSideValidations.enablers[enablers](this);
600
+ ClientSideValidations.enablers[enablers](this);
592
601
  });
593
602
  };
594
603
 
@@ -599,22 +608,22 @@
599
608
  return this;
600
609
  };
601
610
 
602
- $__default['default'].fn.resetClientSideValidations = function () {
611
+ jQuery__default["default"].fn.resetClientSideValidations = function () {
603
612
  this.filter(ClientSideValidations.selectors.forms).each(function () {
604
- return ClientSideValidations.reset(this);
613
+ ClientSideValidations.reset(this);
605
614
  });
606
615
  return this;
607
616
  };
608
617
 
609
- $__default['default'].fn.validate = function () {
618
+ jQuery__default["default"].fn.validate = function () {
610
619
  this.filter(ClientSideValidations.selectors.forms).each(function () {
611
- return $__default['default'](this).enableClientSideValidations();
620
+ jQuery__default["default"](this).enableClientSideValidations();
612
621
  });
613
622
  return this;
614
623
  };
615
624
 
616
- $__default['default'].fn.isValid = function (validators) {
617
- var obj = $__default['default'](this[0]);
625
+ jQuery__default["default"].fn.isValid = function (validators) {
626
+ var obj = jQuery__default["default"](this[0]);
618
627
 
619
628
  if (obj.is('form')) {
620
629
  return validateForm(obj, validators);
@@ -625,7 +634,7 @@
625
634
 
626
635
  var cleanNestedElementName = function cleanNestedElementName(elementName, nestedMatches, validators) {
627
636
  for (var validatorName in validators) {
628
- if (validatorName.match('\\[' + nestedMatches[1] + '\\].*\\[\\]\\[' + nestedMatches[2] + '\\]$')) {
637
+ if (validatorName.match("\\[".concat(nestedMatches[1], "\\].*\\[\\]\\[").concat(nestedMatches[2], "\\]$"))) {
629
638
  elementName = elementName.replace(/\[[\da-z_]+\]\[(\w+)\]$/g, '[][$1]');
630
639
  }
631
640
  }
@@ -652,11 +661,11 @@
652
661
  return validators[cleanElementName(elementName, validators)] || {};
653
662
  };
654
663
 
655
- var validateForm = function validateForm(form, validators) {
664
+ var validateForm = function validateForm($form, validators) {
656
665
  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)) {
666
+ $form.trigger('form:validate:before.ClientSideValidations');
667
+ $form.find(ClientSideValidations.selectors.validate_inputs).each(function () {
668
+ if (!jQuery__default["default"](this).isValid(validators)) {
660
669
  valid = false;
661
670
  }
662
671
 
@@ -664,37 +673,37 @@
664
673
  });
665
674
 
666
675
  if (valid) {
667
- form.trigger('form:validate:pass.ClientSideValidations');
676
+ $form.trigger('form:validate:pass.ClientSideValidations');
668
677
  } else {
669
- form.trigger('form:validate:fail.ClientSideValidations');
678
+ $form.trigger('form:validate:fail.ClientSideValidations');
670
679
  }
671
680
 
672
- form.trigger('form:validate:after.ClientSideValidations');
681
+ $form.trigger('form:validate:after.ClientSideValidations');
673
682
  return valid;
674
683
  };
675
684
 
676
- var passElement = function passElement(element) {
677
- element.trigger('element:validate:pass.ClientSideValidations').data('valid', null);
685
+ var passElement = function passElement($element) {
686
+ $element.trigger('element:validate:pass.ClientSideValidations').data('valid', null);
678
687
  };
679
688
 
680
- var failElement = function failElement(element, message) {
681
- element.trigger('element:validate:fail.ClientSideValidations', message).data('valid', false);
689
+ var failElement = function failElement($element, message) {
690
+ $element.trigger('element:validate:fail.ClientSideValidations', message).data('valid', false);
682
691
  };
683
692
 
684
- var afterValidate = function afterValidate(element) {
685
- return element.trigger('element:validate:after.ClientSideValidations').data('valid') !== false;
693
+ var afterValidate = function afterValidate($element) {
694
+ return $element.trigger('element:validate:after.ClientSideValidations').data('valid') !== false;
686
695
  };
687
696
 
688
- var executeValidator = function executeValidator(validatorFunctions, validatorFunction, validatorOptions, element) {
697
+ var executeValidator = function executeValidator(validatorFunctions, validatorFunction, validatorOptions, $element) {
689
698
  for (var validatorOption in validatorOptions) {
690
699
  if (!validatorOptions[validatorOption]) {
691
700
  continue;
692
701
  }
693
702
 
694
- var message = validatorFunction.call(validatorFunctions, element, validatorOptions[validatorOption]);
703
+ var message = validatorFunction.call(validatorFunctions, $element, validatorOptions[validatorOption]);
695
704
 
696
705
  if (message) {
697
- failElement(element, message);
706
+ failElement($element, message);
698
707
  return false;
699
708
  }
700
709
  }
@@ -702,13 +711,13 @@
702
711
  return true;
703
712
  };
704
713
 
705
- var executeValidators = function executeValidators(validatorFunctions, element, validators) {
714
+ var executeValidators = function executeValidators(validatorFunctions, $element, validators) {
706
715
  for (var validator in validators) {
707
716
  if (!validatorFunctions[validator]) {
708
717
  continue;
709
718
  }
710
719
 
711
- if (!executeValidator(validatorFunctions, validatorFunctions[validator], validators[validator], element)) {
720
+ if (!executeValidator(validatorFunctions, validatorFunctions[validator], validators[validator], $element)) {
712
721
  return false;
713
722
  }
714
723
  }
@@ -716,11 +725,11 @@
716
725
  return true;
717
726
  };
718
727
 
719
- var isMarkedForDestroy = function isMarkedForDestroy(element) {
720
- if (element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
721
- var destroyInputName = element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
728
+ var isMarkedForDestroy = function isMarkedForDestroy($element) {
729
+ if ($element.attr('name').search(/\[([^\]]*?)\]$/) >= 0) {
730
+ var destroyInputName = $element.attr('name').replace(/\[([^\]]*?)\]$/, '[_destroy]');
722
731
 
723
- if ($__default['default']("input[name='" + destroyInputName + "']").val() === '1') {
732
+ if (jQuery__default["default"]("input[name=\"".concat(destroyInputName, "\"]")).val() === '1') {
724
733
  return true;
725
734
  }
726
735
  }
@@ -728,28 +737,28 @@
728
737
  return false;
729
738
  };
730
739
 
731
- var executeAllValidators = function executeAllValidators(element, validators) {
732
- if (element.data('changed') === false || element.prop('disabled')) {
740
+ var executeAllValidators = function executeAllValidators($element, validators) {
741
+ if ($element.data('changed') === false || $element.prop('disabled')) {
733
742
  return;
734
743
  }
735
744
 
736
- element.data('changed', false);
745
+ $element.data('changed', false);
737
746
 
738
- if (executeValidators(ClientSideValidations.validators.all(), element, validators)) {
739
- passElement(element);
747
+ if (executeValidators(ClientSideValidations.validators.all(), $element, validators)) {
748
+ passElement($element);
740
749
  }
741
750
  };
742
751
 
743
- var validateElement = function validateElement(element, validators) {
744
- element.trigger('element:validate:before.ClientSideValidations');
752
+ var validateElement = function validateElement($element, validators) {
753
+ $element.trigger('element:validate:before.ClientSideValidations');
745
754
 
746
- if (isMarkedForDestroy(element)) {
747
- passElement(element);
755
+ if (isMarkedForDestroy($element)) {
756
+ passElement($element);
748
757
  } else {
749
- executeAllValidators(element, validators);
758
+ executeAllValidators($element, validators);
750
759
  }
751
760
 
752
- return afterValidate(element);
761
+ return afterValidate($element);
753
762
  };
754
763
 
755
764
  if (!window.ClientSideValidations) {
@@ -770,4 +779,4 @@
770
779
 
771
780
  return ClientSideValidations;
772
781
 
773
- })));
782
+ }));
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: 17.2.0
4
+ version: 19.1.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: 2020-11-03 00:00:00.000000000 Z
12
+ date: 2021-10-05 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: '6.2'
23
+ version: '7.0'
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: '6.2'
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.3'
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.3'
61
+ version: '2.4'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: byebug
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -73,20 +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.18.0
83
- type: :development
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.18.0
90
76
  - !ruby/object:Gem::Dependency
91
77
  name: m
92
78
  requirement: !ruby/object:Gem::Requirement
@@ -121,14 +107,14 @@ dependencies:
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: '1.11'
110
+ version: '1.13'
125
111
  type: :development
126
112
  prerelease: false
127
113
  version_requirements: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '1.11'
117
+ version: '1.13'
132
118
  - !ruby/object:Gem::Dependency
133
119
  name: rake
134
120
  requirement: !ruby/object:Gem::Requirement
@@ -144,67 +130,39 @@ dependencies:
144
130
  - !ruby/object:Gem::Version
145
131
  version: '13.0'
146
132
  - !ruby/object:Gem::Dependency
147
- name: rubocop
133
+ name: simplecov
148
134
  requirement: !ruby/object:Gem::Requirement
149
135
  requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 1.1.0
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
136
+ - - ">="
158
137
  - !ruby/object:Gem::Version
159
- version: 1.1.0
160
- - !ruby/object:Gem::Dependency
161
- name: rubocop-performance
162
- requirement: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "~>"
138
+ version: 0.18.5
139
+ - - "<"
165
140
  - !ruby/object:Gem::Version
166
- version: '1.8'
141
+ version: '0.22'
167
142
  type: :development
168
143
  prerelease: false
169
144
  version_requirements: !ruby/object:Gem::Requirement
170
145
  requirements:
171
- - - "~>"
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: 0.18.5
149
+ - - "<"
172
150
  - !ruby/object:Gem::Version
173
- version: '1.8'
151
+ version: '0.22'
174
152
  - !ruby/object:Gem::Dependency
175
- name: rubocop-rails
153
+ name: simplecov-lcov
176
154
  requirement: !ruby/object:Gem::Requirement
177
155
  requirements:
178
156
  - - "~>"
179
157
  - !ruby/object:Gem::Version
180
- version: '2.8'
158
+ version: 0.8.0
181
159
  type: :development
182
160
  prerelease: false
183
161
  version_requirements: !ruby/object:Gem::Requirement
184
162
  requirements:
185
163
  - - "~>"
186
164
  - !ruby/object:Gem::Version
187
- version: '2.8'
188
- - !ruby/object:Gem::Dependency
189
- name: simplecov
190
- requirement: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: 0.18.5
195
- - - "<"
196
- - !ruby/object:Gem::Version
197
- version: '0.20'
198
- type: :development
199
- prerelease: false
200
- version_requirements: !ruby/object:Gem::Requirement
201
- requirements:
202
- - - ">="
203
- - !ruby/object:Gem::Version
204
- version: 0.18.5
205
- - - "<"
206
- - !ruby/object:Gem::Version
207
- version: '0.20'
165
+ version: 0.8.0
208
166
  - !ruby/object:Gem::Dependency
209
167
  name: sqlite3
210
168
  requirement: !ruby/object:Gem::Requirement
@@ -248,7 +206,7 @@ dependencies:
248
206
  - !ruby/object:Gem::Version
249
207
  version: '2.1'
250
208
  - !ruby/object:Gem::Dependency
251
- name: thin
209
+ name: webrick
252
210
  requirement: !ruby/object:Gem::Requirement
253
211
  requirements:
254
212
  - - "~>"
@@ -308,7 +266,7 @@ licenses:
308
266
  - MIT
309
267
  metadata:
310
268
  bug_tracker_uri: https://github.com/DavyJonesLocker/client_side_validations/issues
311
- changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/master/CHANGELOG.md
269
+ changelog_uri: https://github.com/DavyJonesLocker/client_side_validations/blob/main/CHANGELOG.md
312
270
  source_code_uri: https://github.com/DavyJonesLocker/client_side_validations
313
271
  post_install_message:
314
272
  rdoc_options: []
@@ -318,14 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
318
276
  requirements:
319
277
  - - ">="
320
278
  - !ruby/object:Gem::Version
321
- version: '2.4'
279
+ version: '2.5'
322
280
  required_rubygems_version: !ruby/object:Gem::Requirement
323
281
  requirements:
324
282
  - - ">="
325
283
  - !ruby/object:Gem::Version
326
284
  version: '0'
327
285
  requirements: []
328
- rubygems_version: 3.1.4
286
+ rubygems_version: 3.1.6
329
287
  signing_key:
330
288
  specification_version: 4
331
289
  summary: Client Side Validations