Skip to content

Commit

Permalink
- bumped 2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumepotier committed Dec 2, 2014
1 parent 1115f5e commit cdd3922
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 38 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Parsley 2.x changelog

## next stable release
## 2.0.6

- removed buggy special char in remote.js plugin (#755)
- fixed bug where isValid returned old errors on field with no constraints
anymore (#776)
- fix a lot of tests

## 2.0.5

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ JavaScript form validation, without actually writing a single line of JavaScript

## Version

2.0.5
2.0.6

## Doc

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parsleyjs",
"version": "2.0.5",
"version": "2.0.6",
"ignore": [
"**/.*",
"build",
Expand Down
35 changes: 23 additions & 12 deletions dist/parsley.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
* Parsleyjs
* Guillaume Potier - <guillaume@wisembly.com>
* Version 2.0.5 - built Wed Oct 15 2014 10:16:06
* Version 2.0.6 - built Tue Dec 02 2014 17:12:12
* MIT Licensed
*
*/
Expand Down Expand Up @@ -1466,7 +1466,7 @@ var Validator = ( function ( ) {
},
_isFieldInGroup: function (field, group) {
if(ParsleyUtils.isArray(field.options.group))
return -1 !== $.inArray(field.options.group, group);
return -1 !== $.inArray(group, field.options.group);
return field.options.group === group;
},
_refreshFields: function () {
Expand Down Expand Up @@ -1557,11 +1557,13 @@ var Validator = ( function ( ) {
this.refreshConstraints();
// Sort priorities to validate more important first
var priorities = this._getConstraintsSortedPriorities();
if (0 === priorities.length)
return this.validationResult = [];
// Value could be passed as argument, needed to add more power to 'parsley:field:validate'
value = value || this.getValue();
// If a field is empty and not required, leave it alone, it's just fine
// Except if `data-parsley-validate-if-empty` explicitely added, useful for some custom validators
if (0 === value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
if (!value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
return this.validationResult = [];
// If we want to validate field against all constraints, just call Validator and let it do the job
if (false === this.options.priorityEnabled)
Expand Down Expand Up @@ -1621,6 +1623,7 @@ var Validator = ( function ( ) {
this.constraints.splice(i, 1);
break;
}
delete this.constraintsByName[name];
return this;
},
// Update a constraint (Remove + re-add)
Expand All @@ -1632,12 +1635,15 @@ var Validator = ( function ( ) {
// Internal only.
// Bind constraints from config + options + DOM
_bindConstraints: function () {
var constraints = [];
var constraints = [], constraintsByName = {};
// clean all existing DOM constraints to only keep javascript user constraints
for (var i = 0; i < this.constraints.length; i++)
if (false === this.constraints[i].isDomConstraint)
if (false === this.constraints[i].isDomConstraint) {
constraints.push(this.constraints[i]);
constraintsByName[this.constraints[i].name] = this.constraints[i];
}
this.constraints = constraints;
this.constraintsByName = constraintsByName;
// then re-add Parsley DOM-API constraints
for (var name in this.options)
this.addConstraint(name, this.options[name]);
Expand Down Expand Up @@ -1666,12 +1672,17 @@ var Validator = ( function ( ) {
var type = this.$element.attr('type');
if ('undefined' === typeof type)
return this;
// Small special case here for HTML5 number, that is in fact an integer validator
if ('number' === type)
return this.addConstraint('type', 'integer', undefined, true);
// Small special case here for HTML5 number: integer validator if step attribute is undefined or an integer value, number otherwise
if ('number' === type) {
if (('undefined' === typeof this.$element.attr('step')) || (0 === parseFloat(this.$element.attr('step')) % 1)) {
return this.addConstraint('type', 'integer', undefined, true);
} else {
return this.addConstraint('type', 'number', undefined, true);
}
// Regular other HTML5 supported types
else if (new RegExp(type, 'i').test('email url range'))
} else if (new RegExp(type, 'i').test('email url range')) {
return this.addConstraint('type', type, undefined, true);
}
return this;
},
// Internal only.
Expand Down Expand Up @@ -1864,15 +1875,15 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
if ('undefined' !== typeof window.ParsleyValidator)
window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);

// Parsley.js 2.0.5
// Parsley.js 2.0.6
// http://parsleyjs.org
// (c) 20012-2014 Guillaume Potier, Wisembly
// Parsley may be freely distributed under the MIT license.

// ### Parsley factory
var Parsley = function (element, options, parsleyFormInstance) {
this.__class__ = 'Parsley';
this.__version__ = '2.0.5';
this.__version__ = '2.0.6';
this.__id__ = ParsleyUtils.hash(4);
// Parsley must be instanciated with a DOM element or jQuery $element
if ('undefined' === typeof element)
Expand Down Expand Up @@ -1935,7 +1946,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
return this;
}
// Remove special chars
multiple = multiple.replace(/(:|\.|\[|\]|\$)/g, '');
multiple = multiple.replace(/(:|\.|\[|\]|\{|\}|\$)/g, '');
// Add proper `data-parsley-multiple` to siblings if we have a valid multiple name
if ('undefined' !== typeof name) {
$('input[name="' + name + '"]').each(function () {
Expand Down
6 changes: 3 additions & 3 deletions dist/parsley.min.js

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions dist/parsley.remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ window.ParsleyExtend = $.extend(window.ParsleyExtend, {
asyncSupport: true,

asyncValidators: $.extend({
default: {
'default': {
fn: function (xhr) {
return 'resolved' === xhr.state();
},
Expand Down Expand Up @@ -259,7 +259,7 @@ window.ParsleyConfig.validators.remote = {
/*!
* Parsleyjs
* Guillaume Potier - <guillaume@wisembly.com>
* Version 2.0.5 - built Wed Oct 15 2014 10:16:06
* Version 2.0.6 - built Tue Dec 02 2014 17:12:12
* MIT Licensed
*
*/
Expand Down Expand Up @@ -1724,7 +1724,7 @@ var Validator = ( function ( ) {
},
_isFieldInGroup: function (field, group) {
if(ParsleyUtils.isArray(field.options.group))
return -1 !== $.inArray(field.options.group, group);
return -1 !== $.inArray(group, field.options.group);
return field.options.group === group;
},
_refreshFields: function () {
Expand Down Expand Up @@ -1815,11 +1815,13 @@ var Validator = ( function ( ) {
this.refreshConstraints();
// Sort priorities to validate more important first
var priorities = this._getConstraintsSortedPriorities();
if (0 === priorities.length)
return this.validationResult = [];
// Value could be passed as argument, needed to add more power to 'parsley:field:validate'
value = value || this.getValue();
// If a field is empty and not required, leave it alone, it's just fine
// Except if `data-parsley-validate-if-empty` explicitely added, useful for some custom validators
if (0 === value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
if (!value.length && !this._isRequired() && 'undefined' === typeof this.options.validateIfEmpty && true !== force)
return this.validationResult = [];
// If we want to validate field against all constraints, just call Validator and let it do the job
if (false === this.options.priorityEnabled)
Expand Down Expand Up @@ -1879,6 +1881,7 @@ var Validator = ( function ( ) {
this.constraints.splice(i, 1);
break;
}
delete this.constraintsByName[name];
return this;
},
// Update a constraint (Remove + re-add)
Expand All @@ -1890,12 +1893,15 @@ var Validator = ( function ( ) {
// Internal only.
// Bind constraints from config + options + DOM
_bindConstraints: function () {
var constraints = [];
var constraints = [], constraintsByName = {};
// clean all existing DOM constraints to only keep javascript user constraints
for (var i = 0; i < this.constraints.length; i++)
if (false === this.constraints[i].isDomConstraint)
if (false === this.constraints[i].isDomConstraint) {
constraints.push(this.constraints[i]);
constraintsByName[this.constraints[i].name] = this.constraints[i];
}
this.constraints = constraints;
this.constraintsByName = constraintsByName;
// then re-add Parsley DOM-API constraints
for (var name in this.options)
this.addConstraint(name, this.options[name]);
Expand Down Expand Up @@ -1924,12 +1930,17 @@ var Validator = ( function ( ) {
var type = this.$element.attr('type');
if ('undefined' === typeof type)
return this;
// Small special case here for HTML5 number, that is in fact an integer validator
if ('number' === type)
return this.addConstraint('type', 'integer', undefined, true);
// Small special case here for HTML5 number: integer validator if step attribute is undefined or an integer value, number otherwise
if ('number' === type) {
if (('undefined' === typeof this.$element.attr('step')) || (0 === parseFloat(this.$element.attr('step')) % 1)) {
return this.addConstraint('type', 'integer', undefined, true);
} else {
return this.addConstraint('type', 'number', undefined, true);
}
// Regular other HTML5 supported types
else if (new RegExp(type, 'i').test('email url range'))
} else if (new RegExp(type, 'i').test('email url range')) {
return this.addConstraint('type', type, undefined, true);
}
return this;
},
// Internal only.
Expand Down Expand Up @@ -2122,15 +2133,15 @@ window.ParsleyConfig.i18n.en = $.extend(window.ParsleyConfig.i18n.en || {}, {
if ('undefined' !== typeof window.ParsleyValidator)
window.ParsleyValidator.addCatalog('en', window.ParsleyConfig.i18n.en, true);

// Parsley.js 2.0.5
// Parsley.js 2.0.6
// http://parsleyjs.org
// (c) 20012-2014 Guillaume Potier, Wisembly
// Parsley may be freely distributed under the MIT license.

// ### Parsley factory
var Parsley = function (element, options, parsleyFormInstance) {
this.__class__ = 'Parsley';
this.__version__ = '2.0.5';
this.__version__ = '2.0.6';
this.__id__ = ParsleyUtils.hash(4);
// Parsley must be instanciated with a DOM element or jQuery $element
if ('undefined' === typeof element)
Expand Down Expand Up @@ -2193,7 +2204,7 @@ if ('undefined' !== typeof window.ParsleyValidator)
return this;
}
// Remove special chars
multiple = multiple.replace(/(:|\.|\[|\]|\$)/g, '');
multiple = multiple.replace(/(:|\.|\[|\]|\{|\}|\$)/g, '');
// Add proper `data-parsley-multiple` to siblings if we have a valid multiple name
if ('undefined' !== typeof name) {
$('input[name="' + name + '"]').each(function () {
Expand Down
6 changes: 3 additions & 3 deletions dist/parsley.remote.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ <h3 class="text-muted"><a href="../">Parsley</a></h3>

<!-- Jumbotron -->
<div class="jumbotron">
<h1>Download <em>Parsley</em> <small>v2.0.5</small></h1>
<h1>Download <em>Parsley</em> <small>v2.0.6</small></h1>
<hr></hr>

<div class="col-md-12"><h2>Whole project..</h2></div>

<div class="col-md-12"><code>$ bower install -S parsleyjs</code></div>
<div class="col-md-12"><code>$ npm install --save parsleyjs</code></div>
<div class="col-md-12"><a href="https://github.com/guillaumepotier/Parsley.js/releases/tag/2.0.5" class="download" data-version="zipball" target="_blank">parsley.zip</a> <small>250ko</small></div>
<div class="col-md-12"><a href="https://github.com/guillaumepotier/Parsley.js/releases/tag/2.0.6" class="download" data-version="zipball" target="_blank">parsley.zip</a> <small>250ko</small></div>

<div class="col-md-12"><h2>..or pick & go!</h2></div>

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ <h3 class="text-muted"><a href="#">Parsley</a></h3>
<h1><em>Parsley</em>, the <strong>ultimate</strong> JavaScript <strong>form validation</strong> library</h1>
<p class="lead">Validating forms frontend have never been so <em>powerful</em> and <em>easy</em>.</p>
<p><a class="btn btn-lg btn-go" href="doc/index.html" role="button">Get started today</a></p>
<p class="version"><i class="icon glyphicon glyphicon-tag"></i>&nbsp;v2.0.5</p>
<p class="version"><i class="icon glyphicon glyphicon-tag"></i>&nbsp;v2.0.6</p>
</div>

<!-- Example row of columns -->
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parsleyjs",
"version": "2.0.5",
"version": "2.0.6",
"homepage": "http://parsleyjs.org",
"license": "MIT",
"description": "Validate your forms, frontend, without writing a single line of javascript!",
Expand Down

0 comments on commit cdd3922

Please sign in to comment.