Skip to content

Commit 6b59fbe

Browse files
committed
Fixed bug in depends-on validation victorjonsson#472
1 parent 4fc0017 commit 6b59fbe

37 files changed

+82
-58
lines changed

form-validator/brazil.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/file.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/html5.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jquery.form-validator.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/** File generated by Grunt -- do not modify
1818
* JQUERY-FORM-VALIDATOR
1919
*
20-
* @version 2.3.33
20+
* @version 2.3.34
2121
* @website http://formvalidator.net/
2222
* @author Victor Jonsson, http://victorjonsson.se
2323
* @license MIT
@@ -903,11 +903,14 @@
903903
var findScriptPathAndLoadModules = function () {
904904
var foundPath = false;
905905
$('script[src*="form-validator"]').each(function () {
906-
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
907-
if (foundPath === '/') {
908-
foundPath = '';
906+
var isScriptFromPluginNodeModulesDirectory = this.src.split('form-validator')[1].split('node_modules').length > 1;
907+
if (!isScriptFromPluginNodeModulesDirectory) {
908+
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
909+
if (foundPath === '/') {
910+
foundPath = '';
911+
}
912+
return false;
909913
}
910-
return false;
911914
});
912915

913916
if (foundPath !== false) {
@@ -940,16 +943,21 @@
940943
* delimiter can be space, comma, dash or pipe
941944
* @param {String} val
942945
* @param {Function|String} [callback]
946+
* @param {Boolean} [allowSpaceAsDelimiter]
943947
* @returns {Array|void}
944948
*/
945-
$.split = function (val, callback) {
949+
$.split = function (val, callback, allowSpaceAsDelimiter) {
950+
// default to true
951+
allowSpaceAsDelimiter = allowSpaceAsDelimiter === undefined || allowSpaceAsDelimiter === true;
952+
var pattern = '[,|\-'+(allowSpaceAsDelimiter ? '\\s':'')+']\\s*',
953+
regex = new RegExp(pattern, 'g');
946954
if (typeof callback !== 'function') {
947955
// return array
948956
if (!val) {
949957
return [];
950958
}
951959
var values = [];
952-
$.each(val.split(callback ? callback : /[,|\-\s]\s*/g),
960+
$.each(val.split(callback ? callback : regex),
953961
function (i, str) {
954962
str = $.trim(str);
955963
if (str.length) {
@@ -960,7 +968,7 @@
960968
return values;
961969
} else if (val) {
962970
// exec callback func on each
963-
$.each(val.split(/[,|\-\s]\s*/g),
971+
$.each(val.split(regex),
964972
function (i, str) {
965973
str = $.trim(str);
966974
if (str.length) {
@@ -1311,7 +1319,7 @@
13111319

13121320
}
13131321

1314-
}, ' ');
1322+
});
13151323

13161324

13171325
if (isValid === false) {

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/jsconf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** File generated by Grunt -- do not modify
22
* JQUERY-FORM-VALIDATOR
33
*
4-
* @version 2.3.33
4+
* @version 2.3.34
55
* @website http://formvalidator.net/
66
* @author Victor Jonsson, http://victorjonsson.se
77
* @license MIT

form-validator/lang/ca.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/cz.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/de.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/dk.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/fr.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/it.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/nl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/no.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pl.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/pt.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ro.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/ru.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/sv.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/lang/vi.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/logic.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/poland.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sanitize.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/security.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sepa.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/sweden.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/toggleDisabled.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/uk.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

formvalidator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"validation",
88
"validator"
99
],
10-
"version": "2.3.33",
10+
"version": "2.3.34",
1111
"author": {
1212
"name": "Victor Jonsson",
1313
"url": "http://victorjonsson.se",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-form-validator",
33
"description": "With this feature rich jQuery plugin it becomes easy to validate user input while keeping your HTML markup clean from javascript code. Even though this plugin has a wide range of validation functions it's designed to require as little bandwidth as possible. This is achieved by grouping together validation functions in \"modules\", making it possible for the programmer to load only those functions that's needed to validate a particular form.",
4-
"version": "2.3.33",
4+
"version": "2.3.34",
55
"main": "./form-validator/jquery.form-validator.min.js",
66
"keywords": [
77
"form",

src/main/module-loader.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,14 @@
114114
var findScriptPathAndLoadModules = function () {
115115
var foundPath = false;
116116
$('script[src*="form-validator"]').each(function () {
117-
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
118-
if (foundPath === '/') {
119-
foundPath = '';
117+
var isScriptFromPluginNodeModulesDirectory = this.src.split('form-validator')[1].split('node_modules').length > 1;
118+
if (!isScriptFromPluginNodeModulesDirectory) {
119+
foundPath = this.src.substr(0, this.src.lastIndexOf('/')) + '/';
120+
if (foundPath === '/') {
121+
foundPath = '';
122+
}
123+
return false;
120124
}
121-
return false;
122125
});
123126

124127
if (foundPath !== false) {

src/main/setup.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@
1111
* delimiter can be space, comma, dash or pipe
1212
* @param {String} val
1313
* @param {Function|String} [callback]
14+
* @param {Boolean} [allowSpaceAsDelimiter]
1415
* @returns {Array|void}
1516
*/
16-
$.split = function (val, callback) {
17+
$.split = function (val, callback, allowSpaceAsDelimiter) {
18+
// default to true
19+
allowSpaceAsDelimiter = allowSpaceAsDelimiter === undefined || allowSpaceAsDelimiter === true;
20+
var pattern = '[,|\-'+(allowSpaceAsDelimiter ? '\\s':'')+']\\s*',
21+
regex = new RegExp(pattern, 'g');
1722
if (typeof callback !== 'function') {
1823
// return array
1924
if (!val) {
2025
return [];
2126
}
2227
var values = [];
23-
$.each(val.split(callback ? callback : /[,|\-\s]\s*/g),
28+
$.each(val.split(callback ? callback : regex),
2429
function (i, str) {
2530
str = $.trim(str);
2631
if (str.length) {
@@ -31,7 +36,7 @@
3136
return values;
3237
} else if (val) {
3338
// exec callback func on each
34-
$.each(val.split(/[,|\-\s]\s*/g),
39+
$.each(val.split(regex),
3540
function (i, str) {
3641
str = $.trim(str);
3742
if (str.length) {

0 commit comments

Comments
 (0)