parsley-rails 2.7.0.0 → 2.8.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
- SHA1:
3
- metadata.gz: '06923dad38a181bc6d0ffe1934efe17577d7782e'
4
- data.tar.gz: 1744e8262e18c968351cfc4104a3f130b87d04f4
2
+ SHA256:
3
+ metadata.gz: b79a31170c5d026f30e041abcb75854a13ee9bd944ed3e8ec7085f5c9d7a4789
4
+ data.tar.gz: 2bf9da88978b2470b6f24c26ceefec3f6846aec9d437094ca4d0c40b23d9b9f9
5
5
  SHA512:
6
- metadata.gz: 7204ceefc835e8445859fdf09ea72944854e611885da4ff05181c63f5a0b9a2df8ce7841ea44011bba80961b1591afb945a146779d4528b627bea5627ee594cf
7
- data.tar.gz: c29694f882374a1157aeda544ea4e4dfec2666edab0514aea2da4f63e6049b6c8cd9bab5bbf00351a9ce05c69643d7ac426d70feea3f8c6e880b3ded73897c1c
6
+ metadata.gz: c9c21f4c71bec8c557669a1d309d95b886f29d55850da21efc3bec6e713a9346466198e4ccaec336c30b54e3ae1cfa2c323988bf9279f718f95e708072ea8b82
7
+ data.tar.gz: e36bc896f0df9b0a8f6af038e6aa60c392cebeb86a7ba2719b9900a56a1a652c710080c8d1c2b5587f66d34c6c33cf591fe22e2cf80e10ed4a801a03a5511ba9
@@ -1,5 +1,5 @@
1
1
  module Parsley
2
2
  module Rails
3
- VERSION = "2.7.0.0"
3
+ VERSION = "2.8.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,29 @@
1
+ // Validation errors messages for Parsley
2
+ // Load this after Parsley
3
+
4
+ Parsley.addMessages('et', {
5
+ defaultMessage: "See väärtus ei sobi.",
6
+ type: {
7
+ email: "See väärtus peab olema kehtiv email.",
8
+ url: "See väärtus peab olema kehtiv link.",
9
+ number: "See väärtus peab olema number.",
10
+ integer: "See väärtus peab olema täisarv.",
11
+ digits: "See väärtus peab olema number.",
12
+ alphanum: "See väärtus peab olema täht või number."
13
+ },
14
+ notblank: "See väärtus ei tohi olla tühi.",
15
+ required: "See väärtus on nõutud.",
16
+ pattern: "See väärtus ei sobi.",
17
+ min: "See väärtus peab olema suurem või võrdne %s.",
18
+ max: "See väärtus peab olema väiksem või võrdne %s.",
19
+ range: "See väärtus peab olema %s ja %s vahel.",
20
+ minlength: "See väärtus on liiga lühike. Peab olema vähemalt %s tähte.",
21
+ maxlength: "See väärtus ei tohi olla rohkem kui %s tähte.",
22
+ length: "See väärtuse pikkus ei sobi. Peab olema vahemikus %s - %s.",
23
+ mincheck: "Pead valima vähemalt %s valikut.",
24
+ maxcheck: "Maksimaalselt %s valikut.",
25
+ check: "Valik peab olema vahemikus %s ja %s .",
26
+ equalto: "See väärtus peab olema sama."
27
+ });
28
+
29
+ Parsley.setLocale('et');
@@ -0,0 +1,29 @@
1
+ // Validation errors messages for Parsley
2
+ // Load this after Parsley
3
+
4
+ Parsley.addMessages('tk', {
5
+ defaultMessage: "Bu maglumat nädogry.",
6
+ type: {
7
+ email: "Dogry e-poçta adresi ýazmaly.",
8
+ url: "Dogry web sahypa salgysy ýazmaly.",
9
+ number: "Dogry san ýazmaly.",
10
+ integer: "Dogry bitin san ýazmaly.",
11
+ digits: "San ýazmaly.",
12
+ alphanum: "San ýa-da harp ýazmaly."
13
+ },
14
+ notblank: "Bu ýeri boş goýmaly däl.",
15
+ required: "Bu ýeri doldurmak hökmany.",
16
+ pattern: "Bu maglumat nädogry.",
17
+ min: "Iň azyndan %s ýa-da ondan uly bolmaly.",
18
+ max: "Iň köp %s ýa-da ondan kiçi bolmaly.",
19
+ range: "Bu ýer %s we %s aralygynda san bolmaly.",
20
+ minlength: "Bu ýeriň uzynlygy iň azyndan %s harp ýa-da ondan köp bolmaly.",
21
+ maxlength: "Bu ýeriň uzynlygy iň köp %s harp ýa-da ondan az bolmaly.",
22
+ length: "Bu ýeriň uzynlygy %s we %s harp aralygynda bolmaly.",
23
+ mincheck: "Iň azyndan %s sanysyny saýlamaly.",
24
+ maxcheck: "Iň köp %s sanysyny saýlamaly.",
25
+ check: "Iň az %s, iň köp %s sanysyny saýlamaly.",
26
+ equalto: "Bu maglumat deň bolmaly."
27
+ });
28
+
29
+ Parsley.setLocale('tk');
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Parsley.js
3
- * Version 2.7.0 - built Wed, Mar 1st 2017, 3:53 pm
3
+ * Version 2.8.1 - built Sat, Feb 3rd 2018, 2:27 pm
4
4
  * http://parsleyjs.org
5
5
  * Guillaume Potier - <guillaume@wisembly.com>
6
6
  * Marc-Andre Lafortune - <petroselinum@marc-andre.ca>
@@ -14,6 +14,8 @@ var _slice = Array.prototype.slice;
14
14
 
15
15
  var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } }; })();
16
16
 
17
+ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
18
+
17
19
  function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } }
18
20
 
19
21
  (function (global, factory) {
@@ -24,10 +26,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
24
26
  var globalID = 1;
25
27
  var pastWarnings = {};
26
28
 
27
- var Utils__Utils = {
29
+ var Utils = {
28
30
  // Parsley DOM-API
29
31
  // returns object from dom attributes and values
30
- attr: function attr($element, namespace, obj) {
32
+ attr: function attr(element, namespace, obj) {
31
33
  var i;
32
34
  var attribute;
33
35
  var attributes;
@@ -40,9 +42,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
40
42
  }
41
43
  }
42
44
 
43
- if ('undefined' === typeof $element || 'undefined' === typeof $element[0]) return obj;
45
+ if (!element) return obj;
44
46
 
45
- attributes = $element[0].attributes;
47
+ attributes = element.attributes;
46
48
  for (i = attributes.length; i--;) {
47
49
  attribute = attributes[i];
48
50
 
@@ -54,12 +56,16 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
54
56
  return obj;
55
57
  },
56
58
 
57
- checkAttr: function checkAttr($element, namespace, _checkAttr) {
58
- return $element.is('[' + namespace + _checkAttr + ']');
59
+ checkAttr: function checkAttr(element, namespace, _checkAttr) {
60
+ return element.hasAttribute(namespace + _checkAttr);
61
+ },
62
+
63
+ setAttr: function setAttr(element, namespace, attr, value) {
64
+ element.setAttribute(this.dasherize(namespace + attr), String(value));
59
65
  },
60
66
 
61
- setAttr: function setAttr($element, namespace, attr, value) {
62
- $element[0].setAttribute(this.dasherize(namespace + attr), String(value));
67
+ getType: function getType(element) {
68
+ return element.getAttribute('type') || 'text';
63
69
  },
64
70
 
65
71
  generateID: function generateID() {
@@ -67,12 +73,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
67
73
  },
68
74
 
69
75
  /** Third party functions **/
70
- // Zepto deserialize function
71
76
  deserializeValue: function deserializeValue(value) {
72
77
  var num;
73
78
 
74
79
  try {
75
- return value ? value == "true" || (value == "false" ? false : value == "null" ? null : !isNaN(num = Number(value)) ? num : /^[\[\{]/.test(value) ? $.parseJSON(value) : value) : value;
80
+ return value ? value == "true" || (value == "false" ? false : value == "null" ? null : !isNaN(num = Number(value)) ? num : /^[\[\{]/.test(value) ? JSON.parse(value) : value) : value;
76
81
  } catch (e) {
77
82
  return value;
78
83
  }
@@ -146,7 +151,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
146
151
  return !/^\s*false\s*$/i.test(string);
147
152
  },
148
153
  object: function object(string) {
149
- return Utils__Utils.deserializeValue(string);
154
+ return Utils.deserializeValue(string);
150
155
  },
151
156
  regexp: function regexp(_regexp) {
152
157
  var flags = '';
@@ -218,8 +223,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
218
223
  _SubmitSelector: 'input[type="submit"], button:submit'
219
224
  };
220
225
 
221
- var Utils__default = Utils__Utils;
222
-
223
226
  // All these options could be overriden and specified directly in DOM using
224
227
  // `data-parsley-` default DOM-API
225
228
  // eg: `inputs` can be set in DOM using `data-parsley-inputs="input, textarea"`
@@ -286,7 +289,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
286
289
  };
287
290
 
288
291
  var Base = function Base() {
289
- this.__id__ = Utils__default.generateID();
292
+ this.__id__ = Utils.generateID();
290
293
  };
291
294
 
292
295
  Base.prototype = {
@@ -304,14 +307,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
304
307
  },
305
308
 
306
309
  actualizeOptions: function actualizeOptions() {
307
- Utils__default.attr(this.$element, this.options.namespace, this.domOptions);
310
+ Utils.attr(this.element, this.options.namespace, this.domOptions);
308
311
  if (this.parent && this.parent.actualizeOptions) this.parent.actualizeOptions();
309
312
  return this;
310
313
  },
311
314
 
312
315
  _resetOptions: function _resetOptions(initOptions) {
313
- this.domOptions = Utils__default.objectCreate(this.parent.options);
314
- this.options = Utils__default.objectCreate(this.domOptions);
316
+ this.domOptions = Utils.objectCreate(this.parent.options);
317
+ this.options = Utils.objectCreate(this.domOptions);
315
318
  // Shallow copy of ownProperties of initOptions:
316
319
  for (var i in initOptions) {
317
320
  if (initOptions.hasOwnProperty(i)) this.options[i] = initOptions[i];
@@ -377,19 +380,19 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
377
380
  },
378
381
 
379
382
  asyncIsValid: function asyncIsValid(group, force) {
380
- Utils__default.warnOnce("asyncIsValid is deprecated; please use whenValid instead");
383
+ Utils.warnOnce("asyncIsValid is deprecated; please use whenValid instead");
381
384
  return this.whenValid({ group: group, force: force });
382
385
  },
383
386
 
384
387
  _findRelated: function _findRelated() {
385
- return this.options.multiple ? this.parent.$element.find('[' + this.options.namespace + 'multiple="' + this.options.multiple + '"]') : this.$element;
388
+ return this.options.multiple ? $(this.parent.element.querySelectorAll('[' + this.options.namespace + 'multiple="' + this.options.multiple + '"]')) : this.$element;
386
389
  }
387
390
  };
388
391
 
389
392
  var convertArrayRequirement = function convertArrayRequirement(string, length) {
390
393
  var m = string.match(/^\s*\[(.*)\]\s*$/);
391
394
  if (!m) throw 'Requirement is not an array: "' + string + '"';
392
- var values = m[1].split(',').map(Utils__default.trimString);
395
+ var values = m[1].split(',').map(Utils.trimString);
393
396
  if (values.length !== length) throw 'Requirement has ' + values.length + ' values when ' + length + ' are needed';
394
397
  return values;
395
398
  };
@@ -400,10 +403,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
400
403
  for (var key in requirementSpec) {
401
404
  if (key) {
402
405
  var value = extraOptionReader(key);
403
- if ('string' === typeof value) value = Utils__default.parseRequirement(requirementSpec[key], value);
406
+ if ('string' === typeof value) value = Utils.parseRequirement(requirementSpec[key], value);
404
407
  extra[key] = value;
405
408
  } else {
406
- main = Utils__default.parseRequirement(requirementSpec[key], string);
409
+ main = Utils.parseRequirement(requirementSpec[key], string);
407
410
  }
408
411
  }
409
412
  return [main, extra];
@@ -426,13 +429,13 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
426
429
  return this.fn(value, requirementFirstArg);
427
430
  }
428
431
 
429
- if ($.isArray(value)) {
432
+ if (Array.isArray(value)) {
430
433
  if (!this.validateMultiple) throw 'Validator `' + this.name + '` does not handle multiple values';
431
434
  return this.validateMultiple.apply(this, arguments);
432
435
  } else {
433
436
  var instance = arguments[arguments.length - 1];
434
437
  if (this.validateDate && instance._isDateInput()) {
435
- arguments[0] = Utils__default.parse.date(arguments[0]);
438
+ arguments[0] = Utils.parse.date(arguments[0]);
436
439
  if (arguments[0] === null) return false;
437
440
  return this.validateDate.apply(this, arguments);
438
441
  }
@@ -454,17 +457,17 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
454
457
  if ('string' !== typeof requirements) {
455
458
  // Assume requirement already parsed
456
459
  // but make sure we return an array
457
- return $.isArray(requirements) ? requirements : [requirements];
460
+ return Array.isArray(requirements) ? requirements : [requirements];
458
461
  }
459
462
  var type = this.requirementType;
460
- if ($.isArray(type)) {
463
+ if (Array.isArray(type)) {
461
464
  var values = convertArrayRequirement(requirements, type.length);
462
- for (var i = 0; i < values.length; i++) values[i] = Utils__default.parseRequirement(type[i], values[i]);
465
+ for (var i = 0; i < values.length; i++) values[i] = Utils.parseRequirement(type[i], values[i]);
463
466
  return values;
464
467
  } else if ($.isPlainObject(type)) {
465
468
  return convertExtraOptionRequirement(type, requirements, extraOptionReader);
466
469
  } else {
467
- return [Utils__default.parseRequirement(type, requirements)];
470
+ return [Utils.parseRequirement(type, requirements)];
468
471
  }
469
472
  },
470
473
  // Defaults:
@@ -484,7 +487,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
484
487
  };
485
488
 
486
489
  var typeTesters = {
487
- email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
490
+ email: /^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/,
488
491
 
489
492
  // Follow https://www.w3.org/TR/html5/infrastructure.html#floating-point-numbers
490
493
  number: /^-?(\d*\.)?\d+(e[-+]?\d+)?$/i,
@@ -497,7 +500,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
497
500
 
498
501
  date: {
499
502
  test: function test(value) {
500
- return Utils__default.parse.date(value) !== null;
503
+ return Utils.parse.date(value) !== null;
501
504
  }
502
505
  },
503
506
 
@@ -518,15 +521,15 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
518
521
  // (first & last IP address of each class)
519
522
  "(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])" + "(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}" + "(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))" + "|" +
520
523
  // host name
521
- '(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)' +
524
+ '(?:(?:[a-zA-Z\\u00a1-\\uffff0-9]-*)*[a-zA-Z\\u00a1-\\uffff0-9]+)' +
522
525
  // domain name
523
- '(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*' +
526
+ '(?:\\.(?:[a-zA-Z\\u00a1-\\uffff0-9]-*)*[a-zA-Z\\u00a1-\\uffff0-9]+)*' +
524
527
  // TLD identifier
525
- '(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))' + ")" +
528
+ '(?:\\.(?:[a-zA-Z\\u00a1-\\uffff]{2,}))' + ")" +
526
529
  // port number
527
530
  "(?::\\d{2,5})?" +
528
531
  // resource path
529
- "(?:/\\S*)?" + "$", 'i')
532
+ "(?:/\\S*)?" + "$")
530
533
  };
531
534
  typeTesters.range = typeTesters.number;
532
535
 
@@ -545,7 +548,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
545
548
 
546
549
  // parseArguments('number', ['1', '2']) => [1, 2]
547
550
  var ValidatorRegistry__parseArguments = function ValidatorRegistry__parseArguments(type, args) {
548
- return args.map(Utils__default.parse[type]);
551
+ return args.map(Utils.parse[type]);
549
552
  };
550
553
  // operatorToValidator returns a validating function for an operator function, applied to the given type
551
554
  var ValidatorRegistry__operatorToValidator = function ValidatorRegistry__operatorToValidator(type, operator) {
@@ -572,7 +575,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
572
575
  init: function init(validators, catalog) {
573
576
  this.catalog = catalog;
574
577
  // Copy prototype's validators:
575
- this.validators = $.extend({}, this.validators);
578
+ this.validators = _extends({}, this.validators);
576
579
 
577
580
  for (var name in validators) this.addValidator(name, validators[name].fn, validators[name].priority);
578
581
 
@@ -628,23 +631,27 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
628
631
  // Old API was addValidator(name, function, priority)
629
632
  //
630
633
  addValidator: function addValidator(name, arg1, arg2) {
631
- if (this.validators[name]) Utils__default.warn('Validator "' + name + '" is already defined.');else if (Defaults.hasOwnProperty(name)) {
632
- Utils__default.warn('"' + name + '" is a restricted keyword and is not a valid validator name.');
634
+ if (this.validators[name]) Utils.warn('Validator "' + name + '" is already defined.');else if (Defaults.hasOwnProperty(name)) {
635
+ Utils.warn('"' + name + '" is a restricted keyword and is not a valid validator name.');
633
636
  return;
634
637
  }
635
638
  return this._setValidator.apply(this, arguments);
636
639
  },
637
640
 
641
+ hasValidator: function hasValidator(name) {
642
+ return !!this.validators[name];
643
+ },
644
+
638
645
  updateValidator: function updateValidator(name, arg1, arg2) {
639
646
  if (!this.validators[name]) {
640
- Utils__default.warn('Validator "' + name + '" is not already defined.');
647
+ Utils.warn('Validator "' + name + '" is not already defined.');
641
648
  return this.addValidator.apply(this, arguments);
642
649
  }
643
650
  return this._setValidator.apply(this, arguments);
644
651
  },
645
652
 
646
653
  removeValidator: function removeValidator(name) {
647
- if (!this.validators[name]) Utils__default.warn('Validator "' + name + '" is not defined.');
654
+ if (!this.validators[name]) Utils.warn('Validator "' + name + '" is not defined.');
648
655
 
649
656
  delete this.validators[name];
650
657
 
@@ -853,14 +860,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
853
860
  this.$element.on('submit.Parsley', function (evt) {
854
861
  _this2.onSubmitValidate(evt);
855
862
  });
856
- this.$element.on('click.Parsley', Utils__default._SubmitSelector, function (evt) {
863
+ this.$element.on('click.Parsley', Utils._SubmitSelector, function (evt) {
857
864
  _this2.onSubmitButton(evt);
858
865
  });
859
866
 
860
867
  // UI could be disabled
861
868
  if (false === this.options.uiEnabled) return;
862
869
 
863
- this.$element.attr('novalidate', '');
870
+ this.element.setAttribute('novalidate', '');
864
871
  },
865
872
 
866
873
  focus: function focus() {
@@ -1008,6 +1015,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1008
1015
  var assert = _ref5.assert;
1009
1016
 
1010
1017
  this._insertErrorWrapper();
1018
+ this._ui.$errorClassHandler.attr('aria-describedby', this._ui.errorsWrapperId);
1011
1019
  this._ui.$errorsWrapper.addClass('filled').append($(this.options.errorTemplate).addClass('parsley-' + name).html(message || this._getErrorMessage(assert)));
1012
1020
  },
1013
1021
 
@@ -1019,6 +1027,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1019
1027
  },
1020
1028
 
1021
1029
  _removeError: function _removeError(name) {
1030
+ this._ui.$errorClassHandler.removeAttr('aria-describedby');
1022
1031
  this._ui.$errorsWrapper.removeClass('filled').find('.parsley-' + name).remove();
1023
1032
  },
1024
1033
 
@@ -1037,7 +1046,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1037
1046
  var _ui = {};
1038
1047
 
1039
1048
  // Give field its Parsley id in DOM
1040
- this.$element.attr(this.options.namespace + 'id', this.__id__);
1049
+ this.element.setAttribute(this.options.namespace + 'id', this.__id__);
1041
1050
 
1042
1051
  /** Generate important UI elements and store them in this **/
1043
1052
  // $errorClassHandler is the $element that woul have parsley-error and parsley-success classes
@@ -1057,37 +1066,50 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1057
1066
 
1058
1067
  // Determine which element will have `parsley-error` and `parsley-success` classes
1059
1068
  _manageClassHandler: function _manageClassHandler() {
1060
- // An element selector could be passed through DOM with `data-parsley-class-handler=#foo`
1069
+ // Class handled could also be determined by function given in Parsley options
1061
1070
  if ('string' === typeof this.options.classHandler && $(this.options.classHandler).length) return $(this.options.classHandler);
1062
1071
 
1063
1072
  // Class handled could also be determined by function given in Parsley options
1064
- var $handler = this.options.classHandler.call(this, this);
1073
+ var $handlerFunction = this.options.classHandler;
1074
+
1075
+ // It might also be the function name of a global function
1076
+ if ('string' === typeof this.options.classHandler && 'function' === typeof window[this.options.classHandler]) $handlerFunction = window[this.options.classHandler];
1065
1077
 
1066
- // If this function returned a valid existing DOM element, go for it
1067
- if ('undefined' !== typeof $handler && $handler.length) return $handler;
1078
+ if ('function' === typeof $handlerFunction) {
1079
+ var $handler = $handlerFunction.call(this, this);
1080
+
1081
+ // If this function returned a valid existing DOM element, go for it
1082
+ if ('undefined' !== typeof $handler && $handler.length) return $handler;
1083
+ } else if ('object' === typeof $handlerFunction && $handlerFunction instanceof jQuery && $handlerFunction.length) {
1084
+ return $handlerFunction;
1085
+ } else if ($handlerFunction) {
1086
+ Utils.warn('The class handler `' + $handlerFunction + '` does not exist in DOM nor as a global JS function');
1087
+ }
1068
1088
 
1069
1089
  return this._inputHolder();
1070
1090
  },
1071
1091
 
1072
1092
  _inputHolder: function _inputHolder() {
1073
1093
  // if simple element (input, texatrea, select...) it will perfectly host the classes and precede the error container
1074
- if (!this.options.multiple || this.$element.is('select')) return this.$element;
1094
+ if (!this.options.multiple || this.element.nodeName === 'SELECT') return this.$element;
1075
1095
 
1076
1096
  // But if multiple element (radio, checkbox), that would be their parent
1077
1097
  return this.$element.parent();
1078
1098
  },
1079
1099
 
1080
1100
  _insertErrorWrapper: function _insertErrorWrapper() {
1081
- var $errorsContainer;
1101
+ var $errorsContainer = this.options.errorsContainer;
1082
1102
 
1083
1103
  // Nothing to do if already inserted
1084
1104
  if (0 !== this._ui.$errorsWrapper.parent().length) return this._ui.$errorsWrapper.parent();
1085
1105
 
1086
- if ('string' === typeof this.options.errorsContainer) {
1087
- if ($(this.options.errorsContainer).length) return $(this.options.errorsContainer).append(this._ui.$errorsWrapper);else Utils__default.warn('The errors container `' + this.options.errorsContainer + '` does not exist in DOM');
1088
- } else if ('function' === typeof this.options.errorsContainer) $errorsContainer = this.options.errorsContainer.call(this, this);
1106
+ if ('string' === typeof $errorsContainer) {
1107
+ if ($($errorsContainer).length) return $($errorsContainer).append(this._ui.$errorsWrapper);else if ('function' === typeof window[$errorsContainer]) $errorsContainer = window[$errorsContainer];else Utils.warn('The errors container `' + $errorsContainer + '` does not exist in DOM nor as a global JS function');
1108
+ }
1109
+
1110
+ if ('function' === typeof $errorsContainer) $errorsContainer = $errorsContainer.call(this, this);
1089
1111
 
1090
- if ('undefined' !== typeof $errorsContainer && $errorsContainer.length) return $errorsContainer.append(this._ui.$errorsWrapper);
1112
+ if ('object' === typeof $errorsContainer && $errorsContainer.length) return $errorsContainer.append(this._ui.$errorsWrapper);
1091
1113
 
1092
1114
  return this._inputHolder().after(this._ui.$errorsWrapper);
1093
1115
  },
@@ -1100,9 +1122,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1100
1122
 
1101
1123
  // Remove Parsley events already bound on this field
1102
1124
  $toBind.off('.Parsley');
1103
- if (this._failedOnce) $toBind.on(Utils__default.namespaceEvents(this.options.triggerAfterFailure, 'Parsley'), function () {
1125
+ if (this._failedOnce) $toBind.on(Utils.namespaceEvents(this.options.triggerAfterFailure, 'Parsley'), function () {
1104
1126
  _this3._validateIfNeeded();
1105
- });else if (trigger = Utils__default.namespaceEvents(this.options.trigger, 'Parsley')) {
1127
+ });else if (trigger = Utils.namespaceEvents(this.options.trigger, 'Parsley')) {
1106
1128
  $toBind.on(trigger, function (event) {
1107
1129
  _this3._validateIfNeeded(event);
1108
1130
  });
@@ -1168,6 +1190,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1168
1190
  var Form = function Form(element, domOptions, options) {
1169
1191
  this.__class__ = 'Form';
1170
1192
 
1193
+ this.element = element;
1171
1194
  this.$element = $(element);
1172
1195
  this.domOptions = domOptions;
1173
1196
  this.options = options;
@@ -1187,10 +1210,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1187
1210
  if (true === event.parsley) return;
1188
1211
 
1189
1212
  // If we didn't come here through a submit button, use the first one in the form
1190
- var $submitSource = this._$submitSource || this.$element.find(Utils__default._SubmitSelector).first();
1191
- this._$submitSource = null;
1213
+ var submitSource = this._submitSource || this.$element.find(Utils._SubmitSelector)[0];
1214
+ this._submitSource = null;
1192
1215
  this.$element.find('.parsley-synthetic-submit-button').prop('disabled', true);
1193
- if ($submitSource.is('[formnovalidate]')) return;
1216
+ if (submitSource && null !== submitSource.getAttribute('formnovalidate')) return;
1217
+
1218
+ window.Parsley._remoteCache = {};
1194
1219
 
1195
1220
  var promise = this.whenValidate({ event: event });
1196
1221
 
@@ -1202,30 +1227,30 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1202
1227
  event.stopImmediatePropagation();
1203
1228
  event.preventDefault();
1204
1229
  if ('pending' === promise.state()) promise.done(function () {
1205
- _this5._submit($submitSource);
1230
+ _this5._submit(submitSource);
1206
1231
  });
1207
1232
  }
1208
1233
  },
1209
1234
 
1210
1235
  onSubmitButton: function onSubmitButton(event) {
1211
- this._$submitSource = $(event.currentTarget);
1236
+ this._submitSource = event.currentTarget;
1212
1237
  },
1213
1238
  // internal
1214
1239
  // _submit submits the form, this time without going through the validations.
1215
1240
  // Care must be taken to "fake" the actual submit button being clicked.
1216
- _submit: function _submit($submitSource) {
1241
+ _submit: function _submit(submitSource) {
1217
1242
  if (false === this._trigger('submit')) return;
1218
1243
  // Add submit button's data
1219
- if ($submitSource) {
1244
+ if (submitSource) {
1220
1245
  var $synthetic = this.$element.find('.parsley-synthetic-submit-button').prop('disabled', false);
1221
1246
  if (0 === $synthetic.length) $synthetic = $('<input class="parsley-synthetic-submit-button" type="hidden">').appendTo(this.$element);
1222
1247
  $synthetic.attr({
1223
- name: $submitSource.attr('name'),
1224
- value: $submitSource.attr('value')
1248
+ name: submitSource.getAttribute('name'),
1249
+ value: submitSource.getAttribute('value')
1225
1250
  });
1226
1251
  }
1227
1252
 
1228
- this.$element.trigger($.extend($.Event('submit'), { parsley: true }));
1253
+ this.$element.trigger(_extends($.Event('submit'), { parsley: true }));
1229
1254
  },
1230
1255
 
1231
1256
  // Performs validation on fields while triggering events.
@@ -1235,7 +1260,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1235
1260
  // Consider using `whenValidate` instead.
1236
1261
  validate: function validate(options) {
1237
1262
  if (arguments.length >= 1 && !$.isPlainObject(options)) {
1238
- Utils__default.warnOnce('Calling validate on a parsley form without passing arguments as an object is deprecated.');
1263
+ Utils.warnOnce('Calling validate on a parsley form without passing arguments as an object is deprecated.');
1239
1264
 
1240
1265
  var _arguments = _slice.call(arguments);
1241
1266
 
@@ -1249,7 +1274,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1249
1274
  },
1250
1275
 
1251
1276
  whenValidate: function whenValidate() {
1252
- var _Utils__default$all$done$fail$always,
1277
+ var _Utils$all$done$fail$always,
1253
1278
  _this6 = this;
1254
1279
 
1255
1280
  var _ref7 = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
@@ -1260,8 +1285,8 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1260
1285
 
1261
1286
  this.submitEvent = event;
1262
1287
  if (event) {
1263
- this.submitEvent = $.extend({}, event, { preventDefault: function preventDefault() {
1264
- Utils__default.warnOnce("Using `this.submitEvent.preventDefault()` is deprecated; instead, call `this.validationResult = false`");
1288
+ this.submitEvent = _extends({}, event, { preventDefault: function preventDefault() {
1289
+ Utils.warnOnce("Using `this.submitEvent.preventDefault()` is deprecated; instead, call `this.validationResult = false`");
1265
1290
  _this6.validationResult = false;
1266
1291
  } });
1267
1292
  }
@@ -1279,7 +1304,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1279
1304
  });
1280
1305
  });
1281
1306
 
1282
- return (_Utils__default$all$done$fail$always = Utils__default.all(promises).done(function () {
1307
+ return (_Utils$all$done$fail$always = Utils.all(promises).done(function () {
1283
1308
  _this6._trigger('success');
1284
1309
  }).fail(function () {
1285
1310
  _this6.validationResult = false;
@@ -1287,7 +1312,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1287
1312
  _this6._trigger('error');
1288
1313
  }).always(function () {
1289
1314
  _this6._trigger('validated');
1290
- })).pipe.apply(_Utils__default$all$done$fail$always, _toConsumableArray(this._pipeAccordingToValidationResult()));
1315
+ })).pipe.apply(_Utils$all$done$fail$always, _toConsumableArray(this._pipeAccordingToValidationResult()));
1291
1316
  },
1292
1317
 
1293
1318
  // Iterate over refreshed fields, and stop on first failure.
@@ -1296,7 +1321,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1296
1321
  // Prefer using `whenValid` instead.
1297
1322
  isValid: function isValid(options) {
1298
1323
  if (arguments.length >= 1 && !$.isPlainObject(options)) {
1299
- Utils__default.warnOnce('Calling isValid on a parsley form without passing arguments as an object is deprecated.');
1324
+ Utils.warnOnce('Calling isValid on a parsley form without passing arguments as an object is deprecated.');
1300
1325
 
1301
1326
  var _arguments2 = _slice.call(arguments);
1302
1327
 
@@ -1326,7 +1351,12 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1326
1351
  return field.whenValid({ group: group, force: force });
1327
1352
  });
1328
1353
  });
1329
- return Utils__default.all(promises);
1354
+ return Utils.all(promises);
1355
+ },
1356
+
1357
+ refresh: function refresh() {
1358
+ this._refreshFields();
1359
+ return this;
1330
1360
  },
1331
1361
 
1332
1362
  // Reset UI
@@ -1375,7 +1405,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1375
1405
  }
1376
1406
  });
1377
1407
 
1378
- $.each(Utils__default.difference(oldFields, _this8.fields), function (_, field) {
1408
+ $.each(Utils.difference(oldFields, _this8.fields), function (_, field) {
1379
1409
  field.reset();
1380
1410
  });
1381
1411
  });
@@ -1411,13 +1441,15 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1411
1441
  var Constraint = function Constraint(parsleyField, name, requirements, priority, isDomConstraint) {
1412
1442
  var validatorSpec = window.Parsley._validatorRegistry.validators[name];
1413
1443
  var validator = new Validator(validatorSpec);
1444
+ priority = priority || parsleyField.options[name + 'Priority'] || validator.priority;
1445
+ isDomConstraint = true === isDomConstraint;
1414
1446
 
1415
- $.extend(this, {
1447
+ _extends(this, {
1416
1448
  validator: validator,
1417
1449
  name: name,
1418
1450
  requirements: requirements,
1419
- priority: priority || parsleyField.options[name + 'Priority'] || validator.priority,
1420
- isDomConstraint: true === isDomConstraint
1451
+ priority: priority,
1452
+ isDomConstraint: isDomConstraint
1421
1453
  });
1422
1454
  this._parseRequirements(parsleyField.options);
1423
1455
  };
@@ -1446,6 +1478,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1446
1478
  var Field = function Field(field, domOptions, options, parsleyFormInstance) {
1447
1479
  this.__class__ = 'Field';
1448
1480
 
1481
+ this.element = field;
1449
1482
  this.$element = $(field);
1450
1483
 
1451
1484
  // Set parent if we have one
@@ -1474,7 +1507,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1474
1507
  // `null` if validation is not finished. Prefer using whenValidate
1475
1508
  validate: function validate(options) {
1476
1509
  if (arguments.length >= 1 && !$.isPlainObject(options)) {
1477
- Utils__default.warnOnce('Calling validate on a parsley field without passing arguments as an object is deprecated.');
1510
+ Utils.warnOnce('Calling validate on a parsley field without passing arguments as an object is deprecated.');
1478
1511
  options = { options: options };
1479
1512
  }
1480
1513
  var promise = this.whenValidate(options);
@@ -1503,7 +1536,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1503
1536
  var group = _ref9.group;
1504
1537
 
1505
1538
  // do not validate a field if not the same as given validation group
1506
- this.refreshConstraints();
1539
+ this.refresh();
1507
1540
  if (group && !this._isInGroup(group)) return;
1508
1541
 
1509
1542
  this.value = this.getValue();
@@ -1538,7 +1571,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1538
1571
  },
1539
1572
 
1540
1573
  _isInGroup: function _isInGroup(group) {
1541
- if ($.isArray(this.options.group)) return -1 !== $.inArray(group, this.options.group);
1574
+ if (Array.isArray(this.options.group)) return -1 !== $.inArray(group, this.options.group);
1542
1575
  return this.options.group === group;
1543
1576
  },
1544
1577
 
@@ -1548,7 +1581,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1548
1581
  // See also `whenValid`.
1549
1582
  isValid: function isValid(options) {
1550
1583
  if (arguments.length >= 1 && !$.isPlainObject(options)) {
1551
- Utils__default.warnOnce('Calling isValid on a parsley field without passing arguments as an object is deprecated.');
1584
+ Utils.warnOnce('Calling isValid on a parsley field without passing arguments as an object is deprecated.');
1552
1585
 
1553
1586
  var _arguments3 = _slice.call(arguments);
1554
1587
 
@@ -1580,7 +1613,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1580
1613
  var _refreshed = _ref10._refreshed;
1581
1614
 
1582
1615
  // Recompute options and rebind constraints to have latest changes
1583
- if (!_refreshed) this.refreshConstraints();
1616
+ if (!_refreshed) this.refresh();
1584
1617
  // do not validate a field if not the same as given validation group
1585
1618
  if (group && !this._isInGroup(group)) return;
1586
1619
 
@@ -1599,13 +1632,13 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1599
1632
  $.each(groupedConstraints, function (_, constraints) {
1600
1633
  // Process one group of constraints at a time, we validate the constraints
1601
1634
  // and combine the promises together.
1602
- var promise = Utils__default.all($.map(constraints, function (constraint) {
1635
+ var promise = Utils.all($.map(constraints, function (constraint) {
1603
1636
  return _this11._validateConstraint(value, constraint);
1604
1637
  }));
1605
1638
  promises.push(promise);
1606
1639
  if (promise.state() === 'rejected') return false; // Interrupt processing if a group has already failed
1607
1640
  });
1608
- return Utils__default.all(promises);
1641
+ return Utils.all(promises);
1609
1642
  },
1610
1643
 
1611
1644
  // @returns a promise
@@ -1616,7 +1649,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1616
1649
  // Map false to a failed promise
1617
1650
  if (false === result) result = $.Deferred().reject();
1618
1651
  // Make sure we return a promise and that we record failures
1619
- return Utils__default.all([result]).fail(function (errorMessage) {
1652
+ return Utils.all([result]).fail(function (errorMessage) {
1620
1653
  if (!(_this12.validationResult instanceof Array)) _this12.validationResult = [];
1621
1654
  _this12.validationResult.push({
1622
1655
  assert: constraint,
@@ -1653,12 +1686,21 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1653
1686
  this._trigger('destroy');
1654
1687
  },
1655
1688
 
1656
- // Actualize options that could have change since previous validation
1657
- // Re-bind accordingly constraints (could be some new, removed or updated)
1658
- refreshConstraints: function refreshConstraints() {
1689
+ // Actualize options and rebind constraints
1690
+ refresh: function refresh() {
1691
+ this._refreshConstraints();
1692
+ return this;
1693
+ },
1694
+
1695
+ _refreshConstraints: function _refreshConstraints() {
1659
1696
  return this.actualizeOptions()._bindConstraints();
1660
1697
  },
1661
1698
 
1699
+ refreshConstraints: function refreshConstraints() {
1700
+ Utils.warnOnce("Parsley's refreshConstraints is deprecated. Please use refresh");
1701
+ return this.refresh();
1702
+ },
1703
+
1662
1704
  /**
1663
1705
  * Add a new constraint to a field
1664
1706
  *
@@ -1725,39 +1767,39 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1725
1767
  // Bind specific HTML5 constraints to be HTML5 compliant
1726
1768
  _bindHtml5Constraints: function _bindHtml5Constraints() {
1727
1769
  // html5 required
1728
- if (this.$element.attr('required')) this.addConstraint('required', true, undefined, true);
1770
+ if (null !== this.element.getAttribute('required')) this.addConstraint('required', true, undefined, true);
1729
1771
 
1730
1772
  // html5 pattern
1731
- if ('string' === typeof this.$element.attr('pattern')) this.addConstraint('pattern', this.$element.attr('pattern'), undefined, true);
1773
+ if (null !== this.element.getAttribute('pattern')) this.addConstraint('pattern', this.element.getAttribute('pattern'), undefined, true);
1732
1774
 
1733
1775
  // range
1734
- if ('undefined' !== typeof this.$element.attr('min') && 'undefined' !== typeof this.$element.attr('max')) this.addConstraint('range', [this.$element.attr('min'), this.$element.attr('max')], undefined, true);
1776
+ var min = this.element.getAttribute('min');
1777
+ var max = this.element.getAttribute('max');
1778
+ if (null !== min && null !== max) this.addConstraint('range', [min, max], undefined, true);
1735
1779
 
1736
1780
  // HTML5 min
1737
- else if ('undefined' !== typeof this.$element.attr('min')) this.addConstraint('min', this.$element.attr('min'), undefined, true);
1781
+ else if (null !== min) this.addConstraint('min', min, undefined, true);
1738
1782
 
1739
1783
  // HTML5 max
1740
- else if ('undefined' !== typeof this.$element.attr('max')) this.addConstraint('max', this.$element.attr('max'), undefined, true);
1784
+ else if (null !== max) this.addConstraint('max', max, undefined, true);
1741
1785
 
1742
1786
  // length
1743
- if ('undefined' !== typeof this.$element.attr('minlength') && 'undefined' !== typeof this.$element.attr('maxlength')) this.addConstraint('length', [this.$element.attr('minlength'), this.$element.attr('maxlength')], undefined, true);
1787
+ if (null !== this.element.getAttribute('minlength') && null !== this.element.getAttribute('maxlength')) this.addConstraint('length', [this.element.getAttribute('minlength'), this.element.getAttribute('maxlength')], undefined, true);
1744
1788
 
1745
1789
  // HTML5 minlength
1746
- else if ('undefined' !== typeof this.$element.attr('minlength')) this.addConstraint('minlength', this.$element.attr('minlength'), undefined, true);
1790
+ else if (null !== this.element.getAttribute('minlength')) this.addConstraint('minlength', this.element.getAttribute('minlength'), undefined, true);
1747
1791
 
1748
1792
  // HTML5 maxlength
1749
- else if ('undefined' !== typeof this.$element.attr('maxlength')) this.addConstraint('maxlength', this.$element.attr('maxlength'), undefined, true);
1793
+ else if (null !== this.element.getAttribute('maxlength')) this.addConstraint('maxlength', this.element.getAttribute('maxlength'), undefined, true);
1750
1794
 
1751
1795
  // html5 types
1752
- var type = this.$element.attr('type');
1753
-
1754
- if ('undefined' === typeof type) return this;
1796
+ var type = Utils.getType(this.element);
1755
1797
 
1756
1798
  // Small special case here for HTML5 number: integer validator if step attribute is undefined or an integer value, number otherwise
1757
1799
  if ('number' === type) {
1758
1800
  return this.addConstraint('type', ['number', {
1759
- step: this.$element.attr('step') || '1',
1760
- base: this.$element.attr('min') || this.$element.attr('value')
1801
+ step: this.element.getAttribute('step') || '1',
1802
+ base: min || this.element.getAttribute('value')
1761
1803
  }], undefined, true);
1762
1804
  // Regular other HTML5 supported types
1763
1805
  } else if (/^(email|url|range|date)$/i.test(type)) {
@@ -1785,11 +1827,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1785
1827
  // Use `data-parsley-whitespace="squish"` to auto squish input value
1786
1828
  // Use `data-parsley-whitespace="trim"` to auto trim input value
1787
1829
  _handleWhitespace: function _handleWhitespace(value) {
1788
- if (true === this.options.trimValue) Utils__default.warnOnce('data-parsley-trim-value="true" is deprecated, please use data-parsley-whitespace="trim"');
1830
+ if (true === this.options.trimValue) Utils.warnOnce('data-parsley-trim-value="true" is deprecated, please use data-parsley-whitespace="trim"');
1789
1831
 
1790
1832
  if ('squish' === this.options.whitespace) value = value.replace(/\s{2,}/g, ' ');
1791
1833
 
1792
- if ('trim' === this.options.whitespace || 'squish' === this.options.whitespace || true === this.options.trimValue) value = Utils__default.trimString(value);
1834
+ if ('trim' === this.options.whitespace || 'squish' === this.options.whitespace || true === this.options.trimValue) value = Utils.trimString(value);
1793
1835
 
1794
1836
  return value;
1795
1837
  },
@@ -1838,14 +1880,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1838
1880
  return this;
1839
1881
  },
1840
1882
 
1841
- // See `Field.refreshConstraints()`
1842
- refreshConstraints: function refreshConstraints() {
1883
+ // See `Field._refreshConstraints()`
1884
+ _refreshConstraints: function _refreshConstraints() {
1843
1885
  var fieldConstraints;
1844
1886
 
1845
1887
  this.constraints = [];
1846
1888
 
1847
1889
  // Select multiple special treatment
1848
- if (this.$element.is('select')) {
1890
+ if (this.element.nodeName === 'SELECT') {
1849
1891
  this.actualizeOptions()._bindConstraints();
1850
1892
 
1851
1893
  return this;
@@ -1860,7 +1902,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1860
1902
  continue;
1861
1903
  }
1862
1904
 
1863
- fieldConstraints = this.$elements[i].data('FieldMultiple').refreshConstraints().constraints;
1905
+ fieldConstraints = this.$elements[i].data('FieldMultiple')._refreshConstraints().constraints;
1864
1906
 
1865
1907
  for (var j = 0; j < fieldConstraints.length; j++) this.addConstraint(fieldConstraints[j].name, fieldConstraints[j].requirements, fieldConstraints[j].priority, fieldConstraints[j].isDomConstraint);
1866
1908
  }
@@ -1874,21 +1916,24 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1874
1916
  if ('function' === typeof this.options.value) return this.options.value(this);else if ('undefined' !== typeof this.options.value) return this.options.value;
1875
1917
 
1876
1918
  // Radio input case
1877
- if (this.$element.is('input[type=radio]')) return this._findRelated().filter(':checked').val() || '';
1919
+ if (this.element.nodeName === 'INPUT') {
1920
+ var type = Utils.getType(this.element);
1921
+ if (type === 'radio') return this._findRelated().filter(':checked').val() || '';
1878
1922
 
1879
- // checkbox input case
1880
- if (this.$element.is('input[type=checkbox]')) {
1881
- var values = [];
1923
+ // checkbox input case
1924
+ if (type === 'checkbox') {
1925
+ var values = [];
1882
1926
 
1883
- this._findRelated().filter(':checked').each(function () {
1884
- values.push($(this).val());
1885
- });
1927
+ this._findRelated().filter(':checked').each(function () {
1928
+ values.push($(this).val());
1929
+ });
1886
1930
 
1887
- return values;
1931
+ return values;
1932
+ }
1888
1933
  }
1889
1934
 
1890
1935
  // Select multiple case
1891
- if (this.$element.is('select') && null === this.$element.val()) return [];
1936
+ if (this.element.nodeName === 'SELECT' && null === this.$element.val()) return [];
1892
1937
 
1893
1938
  // Default case that should never happen
1894
1939
  return this.$element.val();
@@ -1902,6 +1947,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1902
1947
  };
1903
1948
 
1904
1949
  var Factory = function Factory(element, options, parsleyFormInstance) {
1950
+ this.element = element;
1905
1951
  this.$element = $(element);
1906
1952
 
1907
1953
  // If the element has already been bound, returns its saved Parsley instance
@@ -1915,7 +1961,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1915
1961
  }
1916
1962
 
1917
1963
  if ('object' === typeof options) {
1918
- $.extend(savedparsleyFormInstance.options, options);
1964
+ _extends(savedparsleyFormInstance.options, options);
1919
1965
  }
1920
1966
 
1921
1967
  return savedparsleyFormInstance;
@@ -1933,21 +1979,22 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1933
1979
  Factory.prototype = {
1934
1980
  init: function init(options) {
1935
1981
  this.__class__ = 'Parsley';
1936
- this.__version__ = '2.7.0';
1937
- this.__id__ = Utils__default.generateID();
1982
+ this.__version__ = '2.8.1';
1983
+ this.__id__ = Utils.generateID();
1938
1984
 
1939
1985
  // Pre-compute options
1940
1986
  this._resetOptions(options);
1941
1987
 
1942
1988
  // A Form instance is obviously a `<form>` element but also every node that is not an input and has the `data-parsley-validate` attribute
1943
- if (this.$element.is('form') || Utils__default.checkAttr(this.$element, this.options.namespace, 'validate') && !this.$element.is(this.options.inputs)) return this.bind('parsleyForm');
1989
+ if (this.element.nodeName === 'FORM' || Utils.checkAttr(this.element, this.options.namespace, 'validate') && !this.$element.is(this.options.inputs)) return this.bind('parsleyForm');
1944
1990
 
1945
1991
  // Every other element is bound as a `Field` or `FieldMultiple`
1946
1992
  return this.isMultiple() ? this.handleMultiple() : this.bind('parsleyField');
1947
1993
  },
1948
1994
 
1949
1995
  isMultiple: function isMultiple() {
1950
- return this.$element.is('input[type=radio], input[type=checkbox]') || this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple');
1996
+ var type = Utils.getType(this.element);
1997
+ return type === 'radio' || type === 'checkbox' || this.element.nodeName === 'SELECT' && null !== this.element.getAttribute('multiple');
1951
1998
  },
1952
1999
 
1953
2000
  // Multiples fields are a real nightmare :(
@@ -1960,17 +2007,16 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1960
2007
  var parsleyMultipleInstance;
1961
2008
 
1962
2009
  // Handle multiple name
1963
- if (this.options.multiple) ; // We already have our 'multiple' identifier
1964
- else if ('undefined' !== typeof this.$element.attr('name') && this.$element.attr('name').length) this.options.multiple = name = this.$element.attr('name');else if ('undefined' !== typeof this.$element.attr('id') && this.$element.attr('id').length) this.options.multiple = this.$element.attr('id');
2010
+ this.options.multiple = this.options.multiple || (name = this.element.getAttribute('name')) || this.element.getAttribute('id');
1965
2011
 
1966
2012
  // Special select multiple input
1967
- if (this.$element.is('select') && 'undefined' !== typeof this.$element.attr('multiple')) {
2013
+ if (this.element.nodeName === 'SELECT' && null !== this.element.getAttribute('multiple')) {
1968
2014
  this.options.multiple = this.options.multiple || this.__id__;
1969
2015
  return this.bind('parsleyFieldMultiple');
1970
2016
 
1971
2017
  // Else for radio / checkboxes, we need a `name` or `data-parsley-multiple` to properly bind it
1972
2018
  } else if (!this.options.multiple) {
1973
- Utils__default.warn('To be bound by Parsley, a radio, a checkbox and a multiple select input must have either a name or a multiple option.', this.$element);
2019
+ Utils.warn('To be bound by Parsley, a radio, a checkbox and a multiple select input must have either a name or a multiple option.', this.$element);
1974
2020
  return this;
1975
2021
  }
1976
2022
 
@@ -1978,9 +2024,10 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
1978
2024
  this.options.multiple = this.options.multiple.replace(/(:|\.|\[|\]|\{|\}|\$)/g, '');
1979
2025
 
1980
2026
  // Add proper `data-parsley-multiple` to siblings if we have a valid multiple name
1981
- if ('undefined' !== typeof name) {
2027
+ if (name) {
1982
2028
  $('input[name="' + name + '"]').each(function (i, input) {
1983
- if ($(input).is('input[type=radio], input[type=checkbox]')) $(input).attr(_this13.options.namespace + 'multiple', _this13.options.multiple);
2029
+ var type = Utils.getType(input);
2030
+ if (type === 'radio' || type === 'checkbox') input.setAttribute(_this13.options.namespace + 'multiple', _this13.options.multiple);
1984
2031
  });
1985
2032
  }
1986
2033
 
@@ -2011,19 +2058,19 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2011
2058
 
2012
2059
  switch (type) {
2013
2060
  case 'parsleyForm':
2014
- parsleyInstance = $.extend(new Form(this.$element, this.domOptions, this.options), new Base(), window.ParsleyExtend)._bindFields();
2061
+ parsleyInstance = $.extend(new Form(this.element, this.domOptions, this.options), new Base(), window.ParsleyExtend)._bindFields();
2015
2062
  break;
2016
2063
  case 'parsleyField':
2017
- parsleyInstance = $.extend(new parsley_field(this.$element, this.domOptions, this.options, this.parent), new Base(), window.ParsleyExtend);
2064
+ parsleyInstance = $.extend(new parsley_field(this.element, this.domOptions, this.options, this.parent), new Base(), window.ParsleyExtend);
2018
2065
  break;
2019
2066
  case 'parsleyFieldMultiple':
2020
- parsleyInstance = $.extend(new parsley_field(this.$element, this.domOptions, this.options, this.parent), new Multiple(), new Base(), window.ParsleyExtend)._init();
2067
+ parsleyInstance = $.extend(new parsley_field(this.element, this.domOptions, this.options, this.parent), new Multiple(), new Base(), window.ParsleyExtend)._init();
2021
2068
  break;
2022
2069
  default:
2023
2070
  throw new Error(type + 'is not a supported Parsley type');
2024
2071
  }
2025
2072
 
2026
- if (this.options.multiple) Utils__default.setAttr(this.$element, this.options.namespace, 'multiple', this.options.multiple);
2073
+ if (this.options.multiple) Utils.setAttr(this.element, this.options.namespace, 'multiple', this.options.multiple);
2027
2074
 
2028
2075
  if ('undefined' !== typeof doNotStore) {
2029
2076
  this.$element.data('FieldMultiple', parsleyInstance);
@@ -2047,23 +2094,24 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2047
2094
  throw "The loaded version of jQuery is too old. Please upgrade to 1.8.x or better.";
2048
2095
  }
2049
2096
  if (!vernums.forEach) {
2050
- Utils__default.warn('Parsley requires ES5 to run properly. Please include https://github.com/es-shims/es5-shim');
2097
+ Utils.warn('Parsley requires ES5 to run properly. Please include https://github.com/es-shims/es5-shim');
2051
2098
  }
2052
2099
  // Inherit `on`, `off` & `trigger` to Parsley:
2053
- var Parsley = $.extend(new Base(), {
2100
+ var Parsley = _extends(new Base(), {
2101
+ element: document,
2054
2102
  $element: $(document),
2055
2103
  actualizeOptions: null,
2056
2104
  _resetOptions: null,
2057
2105
  Factory: Factory,
2058
- version: '2.7.0'
2106
+ version: '2.8.1'
2059
2107
  });
2060
2108
 
2061
2109
  // Supplement Field and Form with Base
2062
2110
  // This way, the constructors will have access to those methods
2063
- $.extend(parsley_field.prototype, UI.Field, Base.prototype);
2064
- $.extend(Form.prototype, UI.Form, Base.prototype);
2111
+ _extends(parsley_field.prototype, UI.Field, Base.prototype);
2112
+ _extends(Form.prototype, UI.Form, Base.prototype);
2065
2113
  // Inherit actualizeOptions and _resetOptions:
2066
- $.extend(Factory.prototype, Base.prototype);
2114
+ _extends(Factory.prototype, Base.prototype);
2067
2115
 
2068
2116
  // ### jQuery API
2069
2117
  // `$('.elem').parsley(options)` or `$('.elem').psly(options)`
@@ -2079,13 +2127,11 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2079
2127
  }
2080
2128
 
2081
2129
  // Return undefined if applied to non existing DOM element
2082
- if (!$(this).length) {
2083
- Utils__default.warn('You must bind Parsley on an existing element.');
2084
-
2130
+ if (this.length == 0) {
2085
2131
  return;
2086
2132
  }
2087
2133
 
2088
- return new Factory(this, options);
2134
+ return new Factory(this[0], options);
2089
2135
  };
2090
2136
 
2091
2137
  // ### Field and Form extension
@@ -2094,18 +2140,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2094
2140
 
2095
2141
  // ### Parsley config
2096
2142
  // Inherit from ParsleyDefault, and copy over any existing values
2097
- Parsley.options = $.extend(Utils__default.objectCreate(Defaults), window.ParsleyConfig);
2143
+ Parsley.options = _extends(Utils.objectCreate(Defaults), window.ParsleyConfig);
2098
2144
  window.ParsleyConfig = Parsley.options; // Old way of accessing global options
2099
2145
 
2100
2146
  // ### Globals
2101
2147
  window.Parsley = window.psly = Parsley;
2102
- Parsley.Utils = Utils__default;
2148
+ Parsley.Utils = Utils;
2103
2149
  window.ParsleyUtils = {};
2104
- $.each(Utils__default, function (key, value) {
2150
+ $.each(Utils, function (key, value) {
2105
2151
  if ('function' === typeof value) {
2106
2152
  window.ParsleyUtils[key] = function () {
2107
- Utils__default.warnOnce('Accessing `window.ParsleyUtils` is deprecated. Use `window.Parsley.Utils` instead.');
2108
- return Utils__default[key].apply(Utils__default, arguments);
2153
+ Utils.warnOnce('Accessing `window.ParsleyUtils` is deprecated. Use `window.Parsley.Utils` instead.');
2154
+ return Utils[key].apply(Utils, arguments);
2109
2155
  };
2110
2156
  }
2111
2157
  });
@@ -2113,12 +2159,14 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2113
2159
  // ### Define methods that forward to the registry, and deprecate all access except through window.Parsley
2114
2160
  var registry = window.Parsley._validatorRegistry = new ValidatorRegistry(window.ParsleyConfig.validators, window.ParsleyConfig.i18n);
2115
2161
  window.ParsleyValidator = {};
2116
- $.each('setLocale addCatalog addMessage addMessages getErrorMessage formatMessage addValidator updateValidator removeValidator'.split(' '), function (i, method) {
2117
- window.Parsley[method] = $.proxy(registry, method);
2162
+ $.each('setLocale addCatalog addMessage addMessages getErrorMessage formatMessage addValidator updateValidator removeValidator hasValidator'.split(' '), function (i, method) {
2163
+ window.Parsley[method] = function () {
2164
+ return registry[method].apply(registry, arguments);
2165
+ };
2118
2166
  window.ParsleyValidator[method] = function () {
2119
2167
  var _window$Parsley;
2120
2168
 
2121
- Utils__default.warnOnce('Accessing the method \'' + method + '\' through Validator is deprecated. Simply call \'window.Parsley.' + method + '(...)\'');
2169
+ Utils.warnOnce('Accessing the method \'' + method + '\' through Validator is deprecated. Simply call \'window.Parsley.' + method + '(...)\'');
2122
2170
  return (_window$Parsley = window.Parsley)[method].apply(_window$Parsley, arguments);
2123
2171
  };
2124
2172
  });
@@ -2129,18 +2177,18 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2129
2177
  window.ParsleyUI = {
2130
2178
  removeError: function removeError(instance, name, doNotUpdateClass) {
2131
2179
  var updateClass = true !== doNotUpdateClass;
2132
- Utils__default.warnOnce('Accessing UI is deprecated. Call \'removeError\' on the instance directly. Please comment in issue 1073 as to your need to call this method.');
2180
+ Utils.warnOnce('Accessing UI is deprecated. Call \'removeError\' on the instance directly. Please comment in issue 1073 as to your need to call this method.');
2133
2181
  return instance.removeError(name, { updateClass: updateClass });
2134
2182
  },
2135
2183
  getErrorsMessages: function getErrorsMessages(instance) {
2136
- Utils__default.warnOnce('Accessing UI is deprecated. Call \'getErrorsMessages\' on the instance directly.');
2184
+ Utils.warnOnce('Accessing UI is deprecated. Call \'getErrorsMessages\' on the instance directly.');
2137
2185
  return instance.getErrorsMessages();
2138
2186
  }
2139
2187
  };
2140
2188
  $.each('addError updateError'.split(' '), function (i, method) {
2141
2189
  window.ParsleyUI[method] = function (instance, name, message, assert, doNotUpdateClass) {
2142
2190
  var updateClass = true !== doNotUpdateClass;
2143
- Utils__default.warnOnce('Accessing UI is deprecated. Call \'' + method + '\' on the instance directly. Please comment in issue 1073 as to your need to call this method.');
2191
+ Utils.warnOnce('Accessing UI is deprecated. Call \'' + method + '\' on the instance directly. Please comment in issue 1073 as to your need to call this method.');
2144
2192
  return instance[method](name, { message: message, assert: assert, updateClass: updateClass });
2145
2193
  };
2146
2194
  });
@@ -2156,7 +2204,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2156
2204
 
2157
2205
  var o = $({});
2158
2206
  var deprecated = function deprecated() {
2159
- Utils__default.warnOnce("Parsley's pubsub module is deprecated; use the 'on' and 'off' methods on parsley instances or window.Parsley");
2207
+ Utils.warnOnce("Parsley's pubsub module is deprecated; use the 'on' and 'off' methods on parsley instances or window.Parsley");
2160
2208
  };
2161
2209
 
2162
2210
  // Returns an event handler that calls `fn` with the arguments it expects
@@ -2296,7 +2344,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2296
2344
  if (url.indexOf('{value}') > -1) {
2297
2345
  url = url.replace('{value}', encodeURIComponent(value));
2298
2346
  } else {
2299
- data[instance.$element.attr('name') || instance.$element.attr('id')] = value;
2347
+ data[instance.element.getAttribute('name') || instance.element.getAttribute('id')] = value;
2300
2348
  }
2301
2349
 
2302
2350
  // Merge options passed in from the function with the ones in the attribute
@@ -2337,7 +2385,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2337
2385
  Parsley._remoteCache = {};
2338
2386
  });
2339
2387
 
2340
- window.ParsleyExtend.addAsyncValidator = function () {
2388
+ Base.prototype.addAsyncValidator = function () {
2341
2389
  Utils.warnOnce('Accessing the method `addAsyncValidator` through an instance is deprecated. Simply call `Parsley.addAsyncValidator(...)`');
2342
2390
  return Parsley.addAsyncValidator.apply(Parsley, arguments);
2343
2391
  };
@@ -2386,7 +2434,7 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
2386
2434
 
2387
2435
  // Slightly odd way construct our object. This way methods are force bound.
2388
2436
  // Used to test for duplicate library.
2389
- $.extend(this, {
2437
+ _extends(this, {
2390
2438
 
2391
2439
  // For browsers that do not support isTrusted, assumes event is native.
2392
2440
  isNativeEvent: function isNativeEvent(evt) {