parsley-rails 2.0.3.0 → 2.0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3ead0d29389220711f24d0f8b993feeb8888022
4
- data.tar.gz: ed85d75483846cdc1a07568a14cc0dea734367cc
3
+ metadata.gz: 4ea8e40d0a3ca163efbeb80051c637bd6a175f81
4
+ data.tar.gz: d3020a0e39110a6dc56c5baf3419ccf0a42ecf04
5
5
  SHA512:
6
- metadata.gz: 88aaaebacad1390bf8bcb4e9a7b24c5eab2888d1308d95d967e3a7364fa8d7b5b81be9bb2807b8a35223fface6af9eb8a6df1cb0218df3f1f2454332fe35a8b1
7
- data.tar.gz: af872f156ed5310f485a4399d304e1fe62df09c7c378e4e1332b079fd66535b0a335c9debdbdf612d50e86447baf79cfe1df67eb72f34bc507b73e7f482c40c3
6
+ metadata.gz: 6606c6192c1647942f24d3c90a878420f5239935f8b6dc4e75dca7d7ba4b8eaab8e58fd8b2f77c93eae2bb8b0ed5ed1130ca30b50e5df50ad406f76c968384c9
7
+ data.tar.gz: daa68b29c0347330260391fb66bdd84ccca70a2bb0cc2f7597fc37ec4b4a81025cd14c3fec6a0f4abf9b96e4d35d75fb9e4cbfea58c74ed20adc3e59e310ddbd
@@ -1,5 +1,5 @@
1
1
  module Parsley
2
2
  module Rails
3
- VERSION = "2.0.3.0"
3
+ VERSION = "2.0.4.0"
4
4
  end
5
5
  end
@@ -2,5 +2,8 @@ window.ParsleyConfig = window.ParsleyConfig || {};
2
2
  window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
3
3
 
4
4
  window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
5
- dateiso: "This value should be a valid date (YYYY-MM-DD)."
5
+ dateiso: "This value should be a valid date (YYYY-MM-DD).",
6
+ minwords: "This value is too short. It should have %s words or more.",
7
+ maxwords: "This value is too long. It should have %s words or fewer.",
8
+ words: "This value length is invalid. It should be between %s and %s words long."
6
9
  });
@@ -6,22 +6,22 @@ window.ParsleyConfig.i18n = window.ParsleyConfig.i18n || {};
6
6
  window.ParsleyConfig.i18n['pt-br'] = $.extend(window.ParsleyConfig.i18n['pt-br'] || {}, {
7
7
  defaultMessage: "Este valor parece ser inválido.",
8
8
  type: {
9
- email: "Esse campo deve ser um email válido.",
10
- url: "Esse campo deve ser uma url válida.",
11
- number: "Esse campo deve ser um número válido.",
12
- integer: "Esse campo deve ser um inteiro válido.",
13
- digits: "Esse campo deve conter apenas dígitos.",
14
- alphanum: "Esse campo deve ser alfa numérico."
9
+ email: "Este campo deve ser um email válido.",
10
+ url: "Este campo deve ser uma URL válida.",
11
+ number: "Este campo deve ser um número válido.",
12
+ integer: "Este campo deve ser um inteiro válido.",
13
+ digits: "Este campo deve conter apenas dígitos.",
14
+ alphanum: "Este campo deve ser alfa numérico."
15
15
  },
16
- notblank: "Esse campo não pode ficar vazio.",
17
- required: "Esse campo é obrigatório.",
18
- pattern: "Esse campo parece estar inválido.",
19
- min: "Esse campo deve ser maior ou igual a %s.",
20
- max: "Esse campo deve ser menor ou igual a %s.",
21
- range: "Esse campo deve estar entre %s e %s.",
22
- minlength: "Esse campo é pequeno demais. Ele deveria ter %s characteres ou mais.",
23
- maxlength: "Esse campo grande demais. Ele deveri ter %s characteres ou menos.",
24
- length: "O tamanho desse campo é inválido. Ele deveria ter entre %s e %s characteres.",
16
+ notblank: "Este campo não pode ficar vazio.",
17
+ required: "Este campo é obrigatório.",
18
+ pattern: "Este campo parece estar inválido.",
19
+ min: "Este campo deve ser maior ou igual a %s.",
20
+ max: "Este campo deve ser menor ou igual a %s.",
21
+ range: "Este campo deve estar entre %s e %s.",
22
+ minlength: "Este campo é pequeno demais. Ele deveria ter %s caracteres ou mais.",
23
+ maxlength: "Este campo é grande demais. Ele deveria ter %s caracteres ou menos.",
24
+ length: "O tamanho deste campo é inválido. Ele deveria ter entre %s e %s caracteres.",
25
25
  mincheck: "Você deve escolher pelo menos %s opções.",
26
26
  maxcheck: "Você deve escolher %s opções ou mais",
27
27
  check: "Você deve escolher entre %s e %s opções.",
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Parsleyjs
3
3
  * Guillaume Potier - <guillaume@wisembly.com>
4
- * Version 2.0.3 - built Mon Jul 21 2014 11:56:56
4
+ * Version 2.0.4 - built Thu Aug 21 2014 18:04:53
5
5
  * MIT Licensed
6
6
  *
7
7
  */
@@ -197,20 +197,20 @@
197
197
  /*!
198
198
  * validator.js
199
199
  * Guillaume Potier - <guillaume@wisembly.com>
200
- * Version 0.5.8 - built Sun Mar 16 2014 17:18:21
200
+ * Version 1.0.0 - built Sun Aug 03 2014 17:42:31
201
201
  * MIT Licensed
202
202
  *
203
203
  */
204
- ( function ( exports ) {
204
+ ( function ( ) {
205
+ var exports = {};
205
206
  /**
206
207
  * Validator
207
208
  */
208
209
  var Validator = function ( options ) {
209
210
  this.__class__ = 'Validator';
210
- this.__version__ = '0.5.8';
211
+ this.__version__ = '1.0.0';
211
212
  this.options = options || {};
212
213
  this.bindingKey = this.options.bindingKey || '_validatorjsConstraint';
213
- return this;
214
214
  };
215
215
  Validator.prototype = {
216
216
  constructor: Validator,
@@ -293,27 +293,37 @@
293
293
  throw new Error( 'Should give a valid mapping object to Constraint', err, data );
294
294
  }
295
295
  }
296
- return this;
297
296
  };
298
297
  Constraint.prototype = {
299
298
  constructor: Constraint,
300
299
  check: function ( object, group ) {
301
300
  var result, failures = {};
302
- // check all constraint nodes if strict validation enabled. Else, only object nodes that have a constraint
303
- for ( var property in this.options.strict ? this.nodes : object ) {
304
- if ( this.options.strict ? this.has( property, object ) : this.has( property ) ) {
301
+ // check all constraint nodes.
302
+ for ( var property in this.nodes ) {
303
+ var isRequired = false;
304
+ var constraint = this.get(property);
305
+ var constraints = _isArray( constraint ) ? constraint : [constraint];
306
+ for (var i = constraints.length - 1; i >= 0; i--) {
307
+ if ( 'Required' === constraints[i].__class__ ) {
308
+ isRequired = constraints[i].requiresValidation( group );
309
+ continue;
310
+ }
311
+ }
312
+ if ( ! this.has( property, object ) && ! this.options.strict && ! isRequired ) {
313
+ continue;
314
+ }
315
+ try {
316
+ if (! this.has( property, this.options.strict || isRequired ? object : undefined ) ) {
317
+ // we trigger here a HaveProperty Assert violation to have uniform Violation object in the end
318
+ new Assert().HaveProperty( property ).validate( object );
319
+ }
305
320
  result = this._check( property, object[ property ], group );
306
321
  // check returned an array of Violations or an object mapping Violations
307
- if ( ( _isArray( result ) && result.length > 0 ) || ( !_isArray( result ) && !_isEmptyObject( result ) ) )
322
+ if ( ( _isArray( result ) && result.length > 0 ) || ( !_isArray( result ) && !_isEmptyObject( result ) ) ) {
308
323
  failures[ property ] = result;
309
- // in strict mode, get a violation for each constraint node not in object
310
- } else if ( this.options.strict ) {
311
- try {
312
- // we trigger here a HaveProperty Assert violation to have uniform Violation object in the end
313
- new Assert().HaveProperty( property ).validate( object );
314
- } catch ( violation ) {
315
- failures[ property ] = violation;
316
324
  }
325
+ } catch ( violation ) {
326
+ failures[ property ] = violation;
317
327
  }
318
328
  }
319
329
  return _isEmptyObject(failures) ? true : failures;
@@ -422,14 +432,18 @@
422
432
  this.groups = [];
423
433
  if ( 'undefined' !== typeof group )
424
434
  this.addGroup( group );
425
- return this;
426
435
  };
427
436
  Assert.prototype = {
428
437
  construct: Assert,
429
- check: function ( value, group ) {
438
+ requiresValidation: function ( group ) {
430
439
  if ( group && !this.hasGroup( group ) )
431
- return;
440
+ return false;
432
441
  if ( !group && this.hasGroups() )
442
+ return false;
443
+ return true;
444
+ },
445
+ check: function ( value, group ) {
446
+ if ( !this.requiresValidation( group ) )
433
447
  return;
434
448
  try {
435
449
  return this.validate( value, group );
@@ -533,9 +547,9 @@
533
547
  };
534
548
  return this;
535
549
  },
536
- Collection: function ( constraint ) {
550
+ Collection: function ( assertOrConstraint ) {
537
551
  this.__class__ = 'Collection';
538
- this.constraint = 'undefined' !== typeof constraint ? new Constraint( constraint ) : false;
552
+ this.constraint = 'undefined' !== typeof assertOrConstraint ? (assertOrConstraint instanceof Assert ? assertOrConstraint : new Constraint( assertOrConstraint )) : false;
539
553
  this.validate = function ( collection, group ) {
540
554
  var result, validator = new Validator(), count = 0, failures = {}, groups = this.groups.length ? this.groups : group;
541
555
  if ( !_isArray( collection ) )
@@ -579,19 +593,6 @@
579
593
  };
580
594
  return this;
581
595
  },
582
- Eql: function ( eql ) {
583
- this.__class__ = 'Eql';
584
- if ( 'undefined' === typeof eql )
585
- throw new Error( 'Equal must be instanciated with an Array or an Object' );
586
- this.eql = eql;
587
- this.validate = function ( value ) {
588
- var eql = 'function' === typeof this.eql ? this.eql( value ) : this.eql;
589
- if ( !expect.eql( eql, value ) )
590
- throw new Violation( this, value, { eql: eql } );
591
- return true;
592
- };
593
- return this;
594
- },
595
596
  EqualTo: function ( reference ) {
596
597
  this.__class__ = 'EqualTo';
597
598
  if ( 'undefined' === typeof reference )
@@ -645,18 +646,6 @@
645
646
  };
646
647
  return this;
647
648
  },
648
- IPv4: function () {
649
- this.__class__ = 'IPv4';
650
- this.validate = function ( value ) {
651
- var regExp = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
652
- if ( 'string' !== typeof value )
653
- throw new Violation( this, value, { value: Validator.errorCode.must_be_a_string } );
654
- if ( !regExp.test( value ) )
655
- throw new Violation( this, value );
656
- return true;
657
- };
658
- return this;
659
- },
660
649
  Length: function ( boundaries ) {
661
650
  this.__class__ = 'Length';
662
651
  if ( !boundaries.min && !boundaries.max )
@@ -704,18 +693,6 @@
704
693
  };
705
694
  return this;
706
695
  },
707
- Mac: function () {
708
- this.__class__ = 'Mac';
709
- this.validate = function ( value ) {
710
- var regExp = /^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;
711
- if ( 'string' !== typeof value )
712
- throw new Violation( this, value, { value: Validator.errorCode.must_be_a_string } );
713
- if ( !regExp.test( value ) )
714
- throw new Violation( this, value );
715
- return true;
716
- };
717
- return this;
718
- },
719
696
  NotNull: function () {
720
697
  this.__class__ = 'NotNull';
721
698
  this.validate = function ( value ) {
@@ -871,76 +848,22 @@
871
848
  var _isArray = function ( obj ) {
872
849
  return Object.prototype.toString.call( obj ) === '[object Array]';
873
850
  };
874
- // https://github.com/LearnBoost/expect.js/blob/master/expect.js
875
- var expect = {
876
- eql: function ( actual, expected ) {
877
- if ( actual === expected ) {
878
- return true;
879
- } else if ( 'undefined' !== typeof Buffer && Buffer.isBuffer( actual ) && Buffer.isBuffer( expected ) ) {
880
- if ( actual.length !== expected.length ) return false;
881
- for ( var i = 0; i < actual.length; i++ )
882
- if ( actual[i] !== expected[i] ) return false;
883
- return true;
884
- } else if ( actual instanceof Date && expected instanceof Date ) {
885
- return actual.getTime() === expected.getTime();
886
- } else if ( typeof actual !== 'object' && typeof expected !== 'object' ) {
887
- // loosy ==
888
- return actual == expected;
889
- } else {
890
- return this.objEquiv(actual, expected);
891
- }
892
- },
893
- isUndefinedOrNull: function ( value ) {
894
- return value === null || typeof value === 'undefined';
895
- },
896
- isArguments: function ( object ) {
897
- return Object.prototype.toString.call(object) == '[object Arguments]';
898
- },
899
- keys: function ( obj ) {
900
- if ( Object.keys )
901
- return Object.keys( obj );
902
- var keys = [];
903
- for ( var i in obj )
904
- if ( Object.prototype.hasOwnProperty.call( obj, i ) )
905
- keys.push(i);
906
- return keys;
907
- },
908
- objEquiv: function ( a, b ) {
909
- if ( this.isUndefinedOrNull( a ) || this.isUndefinedOrNull( b ) )
910
- return false;
911
- if ( a.prototype !== b.prototype ) return false;
912
- if ( this.isArguments( a ) ) {
913
- if ( !this.isArguments( b ) )
914
- return false;
915
- return eql( pSlice.call( a ) , pSlice.call( b ) );
916
- }
917
- try {
918
- var ka = this.keys( a ), kb = this.keys( b ), key, i;
919
- if ( ka.length !== kb.length )
920
- return false;
921
- ka.sort();
922
- kb.sort();
923
- for ( i = ka.length - 1; i >= 0; i-- )
924
- if ( ka[ i ] != kb[ i ] )
925
- return false;
926
- for ( i = ka.length - 1; i >= 0; i-- ) {
927
- key = ka[i];
928
- if ( !this.eql( a[ key ], b[ key ] ) )
929
- return false;
930
- }
931
- return true;
932
- } catch ( e ) {
933
- return false;
934
- }
935
- }
936
- };
937
- // AMD Compliance
938
- if ( "function" === typeof define && define.amd ) {
939
- define( 'validator', [],function() { return exports; } );
851
+ // AMD export
852
+ if ( typeof define === 'function' && define.amd ) {
853
+ define( 'vendors/validator.js/dist/validator',[],function() {
854
+ return exports;
855
+ } );
856
+ // commonjs export
857
+ } else if ( typeof module !== 'undefined' && module.exports ) {
858
+ module.exports = exports;
859
+ // browser
860
+ } else {
861
+ window[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = exports;
940
862
  }
941
- } )( 'undefined' === typeof exports ? this[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = {} : exports );
942
-
863
+ } )( );
943
864
 
865
+ // This is needed for Browserify usage that requires Validator.js through module.exports
866
+ Validator = 'undefined' !== typeof Validator ? Validator : module.exports;
944
867
  var ParsleyValidator = function (validators, catalog) {
945
868
  this.__class__ = 'ParsleyValidator';
946
869
  this.Validator = Validator;
@@ -1514,7 +1437,7 @@
1514
1437
  // loop through fields to validate them one by one
1515
1438
  for (var i = 0; i < this.fields.length; i++) {
1516
1439
  // do not validate a field if not the same as given validation group
1517
- if (group && group !== this.fields[i].options.group)
1440
+ if (group && !this._isFieldInGroup(this.fields[i], group))
1518
1441
  continue;
1519
1442
  fieldValidationResult = this.fields[i].validate(force);
1520
1443
  if (true !== fieldValidationResult && fieldValidationResult.length > 0 && this.validationResult)
@@ -1528,13 +1451,18 @@
1528
1451
  this._refreshFields();
1529
1452
  for (var i = 0; i < this.fields.length; i++) {
1530
1453
  // do not validate a field if not the same as given validation group
1531
- if (group && group !== this.fields[i].options.group)
1454
+ if (group && !this._isFieldInGroup(this.fields[i], group))
1532
1455
  continue;
1533
1456
  if (false === this.fields[i].isValid(force))
1534
1457
  return false;
1535
1458
  }
1536
1459
  return true;
1537
1460
  },
1461
+ _isFieldInGroup: function (field, group) {
1462
+ if(ParsleyUtils.isArray(field.options.group))
1463
+ return -1 !== $.inArray(field.options.group, group);
1464
+ return field.options.group === group;
1465
+ },
1538
1466
  _refreshFields: function () {
1539
1467
  return this.actualizeOptions()._bindFields();
1540
1468
  },
@@ -1930,7 +1858,7 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
1930
1858
  if ('undefined' !== typeof window.ParsleyValidator)
1931
1859
  window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);
1932
1860
 
1933
- // Parsley.js 2.0.3
1861
+ // Parsley.js 2.0.4
1934
1862
  // http://parsleyjs.org
1935
1863
  // (c) 20012-2014 Guillaume Potier, Wisembly
1936
1864
  // Parsley may be freely distributed under the MIT license.
@@ -1938,7 +1866,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
1938
1866
  // ### Parsley factory
1939
1867
  var Parsley = function (element, options, parsleyFormInstance) {
1940
1868
  this.__class__ = 'Parsley';
1941
- this.__version__ = '2.0.3';
1869
+ this.__version__ = '2.0.4';
1942
1870
  this.__id__ = ParsleyUtils.hash(4);
1943
1871
  // Parsley must be instanciated with a DOM element or jQuery $element
1944
1872
  if ('undefined' === typeof element)
@@ -225,7 +225,7 @@ window.ParsleyExtend = $.extend(window.ParsleyExtend, {
225
225
 
226
226
  _handleRemoteResult: function (validator, xhr, deferred) {
227
227
  // If true, simply resolve and exit
228
- if ('function' === typeof this.asyncValidators[validator].fn && this.asyncValidators[validator].fn(xhr)) {
228
+ if ('function' === typeof this.asyncValidators[validator].fn && this.asyncValidators[validator].fn.call(this, xhr)) {
229
229
  deferred.resolveWith(this);
230
230
 
231
231
  return;
@@ -259,7 +259,7 @@ window.ParsleyConfig.validators.remote = {
259
259
  /*!
260
260
  * Parsleyjs
261
261
  * Guillaume Potier - <guillaume@wisembly.com>
262
- * Version 2.0.3 - built Mon Jul 21 2014 11:56:56
262
+ * Version 2.0.4 - built Thu Aug 21 2014 18:04:53
263
263
  * MIT Licensed
264
264
  *
265
265
  */
@@ -455,20 +455,20 @@ window.ParsleyConfig.validators.remote = {
455
455
  /*!
456
456
  * validator.js
457
457
  * Guillaume Potier - <guillaume@wisembly.com>
458
- * Version 0.5.8 - built Sun Mar 16 2014 17:18:21
458
+ * Version 1.0.0 - built Sun Aug 03 2014 17:42:31
459
459
  * MIT Licensed
460
460
  *
461
461
  */
462
- ( function ( exports ) {
462
+ ( function ( ) {
463
+ var exports = {};
463
464
  /**
464
465
  * Validator
465
466
  */
466
467
  var Validator = function ( options ) {
467
468
  this.__class__ = 'Validator';
468
- this.__version__ = '0.5.8';
469
+ this.__version__ = '1.0.0';
469
470
  this.options = options || {};
470
471
  this.bindingKey = this.options.bindingKey || '_validatorjsConstraint';
471
- return this;
472
472
  };
473
473
  Validator.prototype = {
474
474
  constructor: Validator,
@@ -551,27 +551,37 @@ window.ParsleyConfig.validators.remote = {
551
551
  throw new Error( 'Should give a valid mapping object to Constraint', err, data );
552
552
  }
553
553
  }
554
- return this;
555
554
  };
556
555
  Constraint.prototype = {
557
556
  constructor: Constraint,
558
557
  check: function ( object, group ) {
559
558
  var result, failures = {};
560
- // check all constraint nodes if strict validation enabled. Else, only object nodes that have a constraint
561
- for ( var property in this.options.strict ? this.nodes : object ) {
562
- if ( this.options.strict ? this.has( property, object ) : this.has( property ) ) {
559
+ // check all constraint nodes.
560
+ for ( var property in this.nodes ) {
561
+ var isRequired = false;
562
+ var constraint = this.get(property);
563
+ var constraints = _isArray( constraint ) ? constraint : [constraint];
564
+ for (var i = constraints.length - 1; i >= 0; i--) {
565
+ if ( 'Required' === constraints[i].__class__ ) {
566
+ isRequired = constraints[i].requiresValidation( group );
567
+ continue;
568
+ }
569
+ }
570
+ if ( ! this.has( property, object ) && ! this.options.strict && ! isRequired ) {
571
+ continue;
572
+ }
573
+ try {
574
+ if (! this.has( property, this.options.strict || isRequired ? object : undefined ) ) {
575
+ // we trigger here a HaveProperty Assert violation to have uniform Violation object in the end
576
+ new Assert().HaveProperty( property ).validate( object );
577
+ }
563
578
  result = this._check( property, object[ property ], group );
564
579
  // check returned an array of Violations or an object mapping Violations
565
- if ( ( _isArray( result ) && result.length > 0 ) || ( !_isArray( result ) && !_isEmptyObject( result ) ) )
580
+ if ( ( _isArray( result ) && result.length > 0 ) || ( !_isArray( result ) && !_isEmptyObject( result ) ) ) {
566
581
  failures[ property ] = result;
567
- // in strict mode, get a violation for each constraint node not in object
568
- } else if ( this.options.strict ) {
569
- try {
570
- // we trigger here a HaveProperty Assert violation to have uniform Violation object in the end
571
- new Assert().HaveProperty( property ).validate( object );
572
- } catch ( violation ) {
573
- failures[ property ] = violation;
574
582
  }
583
+ } catch ( violation ) {
584
+ failures[ property ] = violation;
575
585
  }
576
586
  }
577
587
  return _isEmptyObject(failures) ? true : failures;
@@ -680,14 +690,18 @@ window.ParsleyConfig.validators.remote = {
680
690
  this.groups = [];
681
691
  if ( 'undefined' !== typeof group )
682
692
  this.addGroup( group );
683
- return this;
684
693
  };
685
694
  Assert.prototype = {
686
695
  construct: Assert,
687
- check: function ( value, group ) {
696
+ requiresValidation: function ( group ) {
688
697
  if ( group && !this.hasGroup( group ) )
689
- return;
698
+ return false;
690
699
  if ( !group && this.hasGroups() )
700
+ return false;
701
+ return true;
702
+ },
703
+ check: function ( value, group ) {
704
+ if ( !this.requiresValidation( group ) )
691
705
  return;
692
706
  try {
693
707
  return this.validate( value, group );
@@ -791,9 +805,9 @@ window.ParsleyConfig.validators.remote = {
791
805
  };
792
806
  return this;
793
807
  },
794
- Collection: function ( constraint ) {
808
+ Collection: function ( assertOrConstraint ) {
795
809
  this.__class__ = 'Collection';
796
- this.constraint = 'undefined' !== typeof constraint ? new Constraint( constraint ) : false;
810
+ this.constraint = 'undefined' !== typeof assertOrConstraint ? (assertOrConstraint instanceof Assert ? assertOrConstraint : new Constraint( assertOrConstraint )) : false;
797
811
  this.validate = function ( collection, group ) {
798
812
  var result, validator = new Validator(), count = 0, failures = {}, groups = this.groups.length ? this.groups : group;
799
813
  if ( !_isArray( collection ) )
@@ -837,19 +851,6 @@ window.ParsleyConfig.validators.remote = {
837
851
  };
838
852
  return this;
839
853
  },
840
- Eql: function ( eql ) {
841
- this.__class__ = 'Eql';
842
- if ( 'undefined' === typeof eql )
843
- throw new Error( 'Equal must be instanciated with an Array or an Object' );
844
- this.eql = eql;
845
- this.validate = function ( value ) {
846
- var eql = 'function' === typeof this.eql ? this.eql( value ) : this.eql;
847
- if ( !expect.eql( eql, value ) )
848
- throw new Violation( this, value, { eql: eql } );
849
- return true;
850
- };
851
- return this;
852
- },
853
854
  EqualTo: function ( reference ) {
854
855
  this.__class__ = 'EqualTo';
855
856
  if ( 'undefined' === typeof reference )
@@ -903,18 +904,6 @@ window.ParsleyConfig.validators.remote = {
903
904
  };
904
905
  return this;
905
906
  },
906
- IPv4: function () {
907
- this.__class__ = 'IPv4';
908
- this.validate = function ( value ) {
909
- var regExp = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
910
- if ( 'string' !== typeof value )
911
- throw new Violation( this, value, { value: Validator.errorCode.must_be_a_string } );
912
- if ( !regExp.test( value ) )
913
- throw new Violation( this, value );
914
- return true;
915
- };
916
- return this;
917
- },
918
907
  Length: function ( boundaries ) {
919
908
  this.__class__ = 'Length';
920
909
  if ( !boundaries.min && !boundaries.max )
@@ -962,18 +951,6 @@ window.ParsleyConfig.validators.remote = {
962
951
  };
963
952
  return this;
964
953
  },
965
- Mac: function () {
966
- this.__class__ = 'Mac';
967
- this.validate = function ( value ) {
968
- var regExp = /^(?:[0-9A-F]{2}:){5}[0-9A-F]{2}$/i;
969
- if ( 'string' !== typeof value )
970
- throw new Violation( this, value, { value: Validator.errorCode.must_be_a_string } );
971
- if ( !regExp.test( value ) )
972
- throw new Violation( this, value );
973
- return true;
974
- };
975
- return this;
976
- },
977
954
  NotNull: function () {
978
955
  this.__class__ = 'NotNull';
979
956
  this.validate = function ( value ) {
@@ -1129,76 +1106,22 @@ window.ParsleyConfig.validators.remote = {
1129
1106
  var _isArray = function ( obj ) {
1130
1107
  return Object.prototype.toString.call( obj ) === '[object Array]';
1131
1108
  };
1132
- // https://github.com/LearnBoost/expect.js/blob/master/expect.js
1133
- var expect = {
1134
- eql: function ( actual, expected ) {
1135
- if ( actual === expected ) {
1136
- return true;
1137
- } else if ( 'undefined' !== typeof Buffer && Buffer.isBuffer( actual ) && Buffer.isBuffer( expected ) ) {
1138
- if ( actual.length !== expected.length ) return false;
1139
- for ( var i = 0; i < actual.length; i++ )
1140
- if ( actual[i] !== expected[i] ) return false;
1141
- return true;
1142
- } else if ( actual instanceof Date && expected instanceof Date ) {
1143
- return actual.getTime() === expected.getTime();
1144
- } else if ( typeof actual !== 'object' && typeof expected !== 'object' ) {
1145
- // loosy ==
1146
- return actual == expected;
1147
- } else {
1148
- return this.objEquiv(actual, expected);
1149
- }
1150
- },
1151
- isUndefinedOrNull: function ( value ) {
1152
- return value === null || typeof value === 'undefined';
1153
- },
1154
- isArguments: function ( object ) {
1155
- return Object.prototype.toString.call(object) == '[object Arguments]';
1156
- },
1157
- keys: function ( obj ) {
1158
- if ( Object.keys )
1159
- return Object.keys( obj );
1160
- var keys = [];
1161
- for ( var i in obj )
1162
- if ( Object.prototype.hasOwnProperty.call( obj, i ) )
1163
- keys.push(i);
1164
- return keys;
1165
- },
1166
- objEquiv: function ( a, b ) {
1167
- if ( this.isUndefinedOrNull( a ) || this.isUndefinedOrNull( b ) )
1168
- return false;
1169
- if ( a.prototype !== b.prototype ) return false;
1170
- if ( this.isArguments( a ) ) {
1171
- if ( !this.isArguments( b ) )
1172
- return false;
1173
- return eql( pSlice.call( a ) , pSlice.call( b ) );
1174
- }
1175
- try {
1176
- var ka = this.keys( a ), kb = this.keys( b ), key, i;
1177
- if ( ka.length !== kb.length )
1178
- return false;
1179
- ka.sort();
1180
- kb.sort();
1181
- for ( i = ka.length - 1; i >= 0; i-- )
1182
- if ( ka[ i ] != kb[ i ] )
1183
- return false;
1184
- for ( i = ka.length - 1; i >= 0; i-- ) {
1185
- key = ka[i];
1186
- if ( !this.eql( a[ key ], b[ key ] ) )
1187
- return false;
1188
- }
1189
- return true;
1190
- } catch ( e ) {
1191
- return false;
1192
- }
1193
- }
1194
- };
1195
- // AMD Compliance
1196
- if ( "function" === typeof define && define.amd ) {
1197
- define( 'validator', [],function() { return exports; } );
1109
+ // AMD export
1110
+ if ( typeof define === 'function' && define.amd ) {
1111
+ define( 'vendors/validator.js/dist/validator',[],function() {
1112
+ return exports;
1113
+ } );
1114
+ // commonjs export
1115
+ } else if ( typeof module !== 'undefined' && module.exports ) {
1116
+ module.exports = exports;
1117
+ // browser
1118
+ } else {
1119
+ window[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = exports;
1198
1120
  }
1199
- } )( 'undefined' === typeof exports ? this[ 'undefined' !== typeof validatorjs_ns ? validatorjs_ns : 'Validator' ] = {} : exports );
1200
-
1121
+ } )( );
1201
1122
 
1123
+ // This is needed for Browserify usage that requires Validator.js through module.exports
1124
+ Validator = 'undefined' !== typeof Validator ? Validator : module.exports;
1202
1125
  var ParsleyValidator = function (validators, catalog) {
1203
1126
  this.__class__ = 'ParsleyValidator';
1204
1127
  this.Validator = Validator;
@@ -1772,7 +1695,7 @@ window.ParsleyConfig.validators.remote = {
1772
1695
  // loop through fields to validate them one by one
1773
1696
  for (var i = 0; i < this.fields.length; i++) {
1774
1697
  // do not validate a field if not the same as given validation group
1775
- if (group && group !== this.fields[i].options.group)
1698
+ if (group && !this._isFieldInGroup(this.fields[i], group))
1776
1699
  continue;
1777
1700
  fieldValidationResult = this.fields[i].validate(force);
1778
1701
  if (true !== fieldValidationResult && fieldValidationResult.length > 0 && this.validationResult)
@@ -1786,13 +1709,18 @@ window.ParsleyConfig.validators.remote = {
1786
1709
  this._refreshFields();
1787
1710
  for (var i = 0; i < this.fields.length; i++) {
1788
1711
  // do not validate a field if not the same as given validation group
1789
- if (group && group !== this.fields[i].options.group)
1712
+ if (group && !this._isFieldInGroup(this.fields[i], group))
1790
1713
  continue;
1791
1714
  if (false === this.fields[i].isValid(force))
1792
1715
  return false;
1793
1716
  }
1794
1717
  return true;
1795
1718
  },
1719
+ _isFieldInGroup: function (field, group) {
1720
+ if(ParsleyUtils.isArray(field.options.group))
1721
+ return -1 !== $.inArray(field.options.group, group);
1722
+ return field.options.group === group;
1723
+ },
1796
1724
  _refreshFields: function () {
1797
1725
  return this.actualizeOptions()._bindFields();
1798
1726
  },
@@ -2188,7 +2116,7 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
2188
2116
  if ('undefined' !== typeof window.ParsleyValidator)
2189
2117
  window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);
2190
2118
 
2191
- // Parsley.js 2.0.3
2119
+ // Parsley.js 2.0.4
2192
2120
  // http://parsleyjs.org
2193
2121
  // (c) 20012-2014 Guillaume Potier, Wisembly
2194
2122
  // Parsley may be freely distributed under the MIT license.
@@ -2196,7 +2124,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
2196
2124
  // ### Parsley factory
2197
2125
  var Parsley = function (element, options, parsleyFormInstance) {
2198
2126
  this.__class__ = 'Parsley';
2199
- this.__version__ = '2.0.3';
2127
+ this.__version__ = '2.0.4';
2200
2128
  this.__id__ = ParsleyUtils.hash(4);
2201
2129
  // Parsley must be instanciated with a DOM element or jQuery $element
2202
2130
  if ('undefined' === typeof element)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parsley-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3.0
4
+ version: 2.0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiri Pospisil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties